A few years ago, prototyping a simple shopping cart in Figma meant duplicating the same screen ten times. One with zero items, one with one item, one with two, and a spaghetti bowl of noodles connecting them. Change the button colour and you'd update it in ten places.
Variables changed that. With Figma variables and advanced prototyping, one screen can remember values, react to them and change what it shows. A cart can count. A form can check whether a field is filled. A toggle can switch the whole prototype into dark mode.
This guide covers what variables are, how they work in prototypes, and practical patterns you can build today. If you want to use variables for design tokens and theming, I've covered that side in Figma design system setup. Here, the focus is interaction.
What Figma variables are
A variable is a named, reusable value. You create variables in collections from the Local variables panel, and you can bind them to design properties or change them during a prototype.
Figma supports four variable types:
| Type | Holds | Bind it to | Prototype example |
|---|---|---|---|
| Colour | A colour value | Fills, strokes | Highlight a selected card |
| Number | A number | Width, height, padding, gap, corner radius, text | Cart count, quantity stepper, progress |
| String | Text | Text layers, variant properties | Username, selected plan name |
| Boolean | True or false | Layer visibility, boolean variant properties | Show an error, open a menu, toggle a setting |
The key idea for prototyping: when a variable's value changes, every layer bound to it updates instantly. That's what lets one screen behave like many.
Feature availability, such as how many modes a collection can have, depends on your Figma plan. Check Figma's help centre for current limits before you plan a big prototype around them.
Modes: one design, many contexts
Modes let a collection hold different values for the same variable. A "Theme" collection might have Light and Dark modes. A "Language" collection might have English and Hindi modes for string variables. A "Device" collection might hold different spacing numbers for mobile and desktop.
You can set a mode on a frame or section, and child layers inherit it. In prototypes, the Set variable mode action switches modes on interaction, so a single toggle can flip your entire prototype from light to dark, or from English to Hindi, without duplicating a screen.
The prototyping actions that use variables
Set variable
The Set variable action changes a variable's value when an interaction happens: on click, on drag, after a delay and so on. You can set a fixed value ("isMenuOpen = true") or use an expression ("cartCount + 1").
Conditional
The Conditional action adds if/else logic. "If cartCount is greater than 0, navigate to Checkout; else show the empty cart message." You can nest actions inside each branch.
Multiple actions
A single interaction can run several actions in order. A tap on "Add to cart" can increase the count, set a "justAdded" boolean to show a toast, and change the button's variant, all at once.
Expressions in Figma prototypes
Expressions let you calculate a value instead of typing a fixed one. In general you can:
- Do arithmetic with numbers: add, subtract, multiply and divide, such as
quantity * price. - Join strings: combine text, such as a greeting plus a name.
- Compare values: equal, not equal, greater than, less than, for use in conditionals.
- Combine booleans: and, or, not, such as "email is filled and terms accepted".
Expressions are written inside the variable value field of an action or condition. Keep them simple. If an expression needs a comment to explain it, split the logic into smaller steps.
Tip
Name variables the way a developer would read them, like
cartCount,isLoggedInorselectedPlan. Booleans that start with "is" or "has" make conditionals read almost like English.
Five practical patterns to build
1. A working cart counter
Create a number variable cartCount set to 0. Bind it to the text in your cart badge. On the "Add" button, use Set variable: cartCount + 1. Add a boolean hasItems or use a conditional on cartCount > 0 to show or hide the badge.
2. A quantity stepper with limits
Use a number variable for quantity. The plus button runs a conditional: if quantity is less than 10, add one. The minus button: if quantity is greater than 1, subtract one. Bind a total price text to an expression of quantity and price to show live totals.
3. Form validation
Create booleans like isNameFilled and isTermsAccepted. Interactions on inputs set them to true. The submit button runs a conditional: if both are true, navigate to success; else set showError to true, which makes an error message visible.
4. A light and dark mode toggle
Bind your colours to a collection with Light and Dark modes. A toggle switch uses Set variable mode to change the mode. Stakeholders can test both themes in one prototype, which helps when reviewing dark mode designs.
5. Personalised content
Set a string variable userName during a fake sign-up and bind it to greetings across screens. Your prototype now feels personal throughout, which makes usability tests more believable.
From my work
At Ksolves, I prototype interactive flows for stakeholder reviews. A prototype that responds properly, rather than jumping between static screens, makes it much easier for people to judge the experience instead of guessing how it will behave.
Pitfalls and how to avoid them
Watch out
Variable values persist as you move between screens in a prototype session, and reset when the prototype restarts. If a test participant reloads midway, their cart empties. Plan your test script around that.
- Logic sprawl. Ten conditionals on one button become impossible to debug. Move logic into interactive components where it makes sense.
- Unclear naming.
var1andtoggle copywill confuse you next week. Use clear, consistent names and group them in a dedicated prototype collection. - Mixing tokens and prototype state. Keep design tokens (colours, spacing) separate from prototype state variables (counts, booleans) so your design system stays clean.
- Over-building. A prototype exists to answer a question. If simple screen links answer it, stop there.
A quick setup checklist
- Write down what the prototype needs to test before adding any logic.
- Create a separate collection for prototype state variables.
- Name variables clearly, with "is" or "has" for booleans.
- Bind variables to layers and test each interaction in presentation view.
- Document the logic in a note on the canvas for teammates and developers.
- Run one full test before sharing, including a restart.
For handing all this over, my developer handoff checklist helps make sure the logic you prototyped is explained, not just shown.
Key takeaways
- Figma variables come in four types: colour, number, string and boolean.
- Set variable, Set variable mode and Conditional actions turn static screens into responsive prototypes.
- Expressions handle arithmetic, text joining, comparisons and boolean logic.
- Modes let one prototype switch themes, languages or device contexts.
- Keep logic simple, names clear and prototype state separate from design tokens.
Work with us
Want this set up properly? Our design system agency builds Figma libraries, tokens and documentation that scale with your team.
FAQ
Can you use conditional logic in Figma prototypes?
Yes. The Conditional prototype action lets you add if/else logic based on variable values, such as navigating to different screens depending on whether a form is complete. You can combine it with Set variable and multiple actions on a single interaction.
What are modes in Figma variables?
Modes let one variable collection hold different values for the same variables, such as Light and Dark themes or different languages. You can apply a mode to a frame and switch modes in a prototype with the Set variable mode action. The number of modes available depends on your plan.
Do I need variables for every Figma prototype?
No. Simple click-through prototypes are often enough for early ideas and quick feedback. Use variables when a realistic prototype needs to remember state, like counts, selections or form inputs, or when you want to test themes and languages without duplicating screens.
What to do next
Open a file you're working on and rebuild one multi-screen interaction, like a cart or a toggle, using a single variable. Once you feel how much cleaner it is, the rest follows quickly.
If you need high-fidelity, testable prototypes for your product or investor demo, tell me about your project.