Figma Expressions: Dynamic Prototypes with Logic and Math
Figma expressions are like mini-formulas in your prototype, letting you manipulate variables with math and logic. Use them to build shopping carts that calculate totals or progress bars that fill up.
Why it exists
Prototyping with basic variables can require dozens of frames to simulate dynamic behavior like a changing shopping cart total. Expressions were created to solve this by allowing prototypes to perform calculations and evaluations, bridging the gap between static mockups and real, logic-driven applications.
The mental model
Think of expressions as spreadsheet formulas for your design. Instead of only setting a variable to a fixed value (like quantity = 1), you can set it to a calculated value (quantity = quantity + 1). This lets your prototype react dynamically to user interactions using logic, not just pre-linked screens.
How it works
An expression combines values (like a number 10 or a variable price) with operators (like + for addition). You write them directly into the input fields of two specific prototype actions. First, the Set variable action, to change a variable's value based on the expression's result. Second, the Conditional action, to create an if statement that runs only if the boolean expression evaluates to true. Figma validates your syntax in real-time, outlining invalid expressions in red.
When to use it
Use expressions when your prototype needs to calculate, combine, or evaluate something based on user input. This is ideal for building interactive components like a shopping cart that calculates a running total, a volume slider that scales an object's size, or a welcome message that combines a user's name with a static greeting string.
When not to use it
Avoid expressions for simple state changes that are better handled by component variants. If you're just swapping an icon from 'off' to 'on', a simple OnClick > Change to interaction is faster and clearer. Expressions are for dynamic logic, not just visual swaps. They are also a feature of paid Figma plans and will not work on the free tier.
One canonical example
To create a quantity counter, first define a number variable called itemCount with a default value of 1. Create a '+' button. For its OnClick interaction, choose the Set variable action, select itemCount, and in the to field, type the expression itemCount + 1. Now, clicking the button will dynamically increment the variable's value, which can be displayed in a text layer on your prototype.
Interview question
Which prototyping scenario most effectively leverages Figma expressions over simpler interaction methods?
- a.Changing a button's color when a user hovers over it.
- b.Calculating and displaying a running total for items added to a shopping cart.Correct
- c.Switching between different artboards in a linear user flow.
- d.Toggling a checkbox's visual state between checked and unchecked.
Why? this is the answer
Expressions are specifically for dynamic calculations and evaluations, such as updating a shopping cart total based on user input. Simple state changes like toggling a checkbox are better managed with component variants, not expressions.
Just read this? Test yourself on what you have been reading.
Read the original → help.figma.com
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on figma — each one lists the topics its interview covers.
See open roles