0
100
200
300
400
500
600
700
800
900
1000
1100
0
100
200
300
400
500
600
700
800
900
1000
1100
Guide · Variables & styles

How to Toggle a Boolean Variable to Show and Hide Layers in Figma

To show and hide a layer with a boolean variable, create a Boolean variable, right-click the eye icon in the layer's Appearance section and bind the variable to visibility. Then add an On click → Set variable interaction that sets the variable to ! itself (or not itself), so each click flips it between true and false.

When the variable is true the layer is visible, and when it's false the layer is hidden. Any plan can create variables and bind them to visibility, but using variables in a prototype needs a paid plan.

Updated Sep 24, 20265 min read
On this page
6 steps

Quick steps

1

Create a Boolean variable

Open the Variables tab in the left navigation, click + Create variable, choose Boolean and name it, for example menuOpen. Set the default value to false.

2

Bind it to the layer's visibility

Select the layer to show or hide. In the Appearance section of the right sidebar, right-click the eye icon and pick the boolean variable.

3

Select the trigger layer

Switch to the Prototype tab and select the button or icon that should do the toggling.

4

Add a Set variable action

Add an interaction with the On click trigger and the Set variable action. Pick menuOpen as the variable to change.

5

Enter the toggle expression

In the 'to' field, type the expression ! menuOpen (or not menuOpen) and press Enter or Return. Each click now sets the variable to the opposite of its current value.

6

Preview the prototype

Press Shift+Space to preview, or present the prototype, and click the trigger a few times to check the layer appears and disappears.

01

How does a boolean variable control visibility?

Figma's help center defines it directly: "If the value of the boolean variable is true then the layer will be visible. If the value of the boolean variable is false then the layer will be hidden." You bind it by right-clicking the visibility (eye) icon in the Appearance section. The normal variable picker on fills and text won't list boolean variables, which is the first thing that trips people up.

Because the value lives in a variable, several layers can share it. Bind a dropdown panel and a dimmed backdrop to the same menuOpen variable and one click shows or hides both. If you haven't created a variable before, start with how to create variables in Figma.

02

How to set a variable in a Figma prototype

The Set variable action changes a variable's value when the trigger fires. For a boolean you can enter true or false, pick another boolean variable, or write an expression. To toggle, the expression negates the current value. Figma's expressions support ! or not for negation, so ! menuOpen and not menuOpen both work. You can type the expression in the field or build it from the selection panel of suggested variables and operators.

A forum thread on exactly this question ("on click toggle boolean variable to show/hide elements") has over 33,000 views, so if you got stuck here, you're in good company.

03

Example: an accordion with one variable per row

Create a boolean for each row, such as faq1Open and faq2Open, all set to false. Bind each answer layer's visibility to its row's variable. On each question, add On click → Set variable → ! faq1Open (and so on). Put the rows in a vertical auto layout frame, so when an answer is hidden the rows below move up and close the gap. The same pattern covers a password field's show/hide icon or a settings toggle.

04

Conditional prototypes: if/else with booleans

When one click should do different things depending on state, use a Conditional action instead of a plain toggle. Set the condition to the boolean, for example menuOpen == true, then add the actions to run when it's true and a different set under else. Expressions also support and, or, == and !=, so you can check two variables at once, such as whether a user is logged in and a form is complete.

  • Use Set variable alone for simple toggles: menus, accordions, checkboxes, a password eye icon.
  • Use Conditional when the click should branch: navigate to one screen if a checkbox is ticked, show an error overlay if not.
  • Use Set variable mode when you want to switch a whole theme, like light to dark. See variable modes and dark mode.
05

Figma boolean variable not working: common causes

  1. The variable is bound to the wrong thing. A boolean variable only controls visibility through the eye icon. Right-click the eye icon in the Appearance section and confirm the variable is selected there.
  2. The action sets a fixed value. If the Set variable action says true, the first click shows the layer and later clicks do nothing. Replace it with ! menuOpen so it flips each time.
  3. You're on a free plan. Using variables in prototypes, including Set variable, conditionals and expressions, is available on paid plans only.
  4. The default value hides the trigger. If the button itself is bound to the variable, setting it to false hides the button too. Bind only the content that should appear and disappear.
Boolean variables and boolean component properties are different features. A boolean component property shows or hides a layer inside a component instance from the right sidebar. The Set variable action changes variables, so for click-to-toggle in a prototype, use a variable.
Ranked listThe best Figma design token and variables plugins in 2026
FAQ

Frequently asked questions

How do I toggle a boolean variable in Figma?

Add an On click interaction with the Set variable action, pick the boolean variable, and set it to the expression ! yourVariable (or not yourVariable). Each click sets it to the opposite of its current value.

Why can't I apply a boolean variable to my layer?

Boolean variables only bind to layer visibility. Right-click the eye icon in the Appearance section of the right sidebar instead of using the fill or text variable picker.

Do variables in prototypes work on the free plan?

No. Figma lists prototyping with variables as available on any paid plan. You can still create boolean variables and bind them to visibility on Starter, but the prototype actions need a paid plan.

What is a conditional prototype in Figma?

It's a Conditional action that checks an expression, such as menuOpen == true, and runs one set of actions if it's true and another under else. It lets a single click branch based on the state stored in variables.

Keep learning

More in Variables & styles

All guides in Variables & styles