Skip to main content
July 11, 2023

Invert boolean variable for layer display

  • July 11, 2023
  • 45 replies
  • 9501 views

Right now, tying layer visibility to a variable means if the boolean is false = layer is hidden. It’d be great if we could invert this functionality (boolean is false = layer is shown) on a per-layer basis as I need to show some layers and hide others depending on the state of the variable.

Anyone else run into this?

45 replies

November 13, 2023

I would make this request wider than just inverting. Why not providing the option to compare?
This way, you could do [if myVariable == true], [if myVariable == false], [if myVariable == “step1”], [if myVariable != “step1”], [if myVariable >= 3]

Desislava_Slavkova
Active Member
December 19, 2023

Please add this, it would save so much time! And I’d love to do comparison and invert in the interaction panel as well where assigning variables directly on layer visibility.

Johan_Svahn
January 14, 2024

For me this exclude-trick works when presenting the prototype in a browser, but not in Figma app on mobile. Neither on Android nor iPhone.

Elliott_UX
New Participant
January 26, 2024

Adding my +1 to this.

elias_alegria
February 2, 2024

If you change the element visibility in layer panel, it will invert the boolean rule automatically

Ray19
New Member
February 19, 2024

here’s a solution that creates a custom boolean:

  1. in the master component properties create variant with the Values “Yes” and “No”.
  2. create a variant of the component with the layers configured the way you want and assign the new boolean variant.
  3. the new variant property will appear in the instance properties as a toggle switch.

March 6, 2024

If you change the element visibility in layer panel, it will invert the boolean rule automatically

It doesn’t invert the rule, it just toggles the value.

March 6, 2024

For anyone else trying to figure this trick out, it doesn’t work on frames.

It relies on having two identical shapes. When only one is visible, it’s shown. When both are visible, the exclude operation kicks in and hides them both.

It does work on text as long as the two layers overlap perfectly. You can use a text variable to get the exact same text within multiple text layers.

Laurent_Gaulhiac
March 25, 2024

I am building a fairly complex app.
To manage the state of the panels, I rely on the Layer Visibility with booleans. I have to set up almost every booleans twice, like:

  • is_EditModeActive?
  • is_EditModeInactive?

Then I need A LOT of conditional branching and twice the amount of “set variables” to achieve what I need.

A simple custom variable defined like is_EditModeInactive? = !{is_EditModeActive?} or a simple “boolean inverter” while right-clicking the “Eye” icon at the Layer level will make complex work WAY easier. Now it’s a nightmare for advanced prototypes.

cupps
March 29, 2024

Agree with this request. I find myself really limited by booleans without them acting as more of a boolean toggle for the layer, and being able to set a layers default state for the boolean mode. Boolean supporting showing or hiding of a layer vs the boolean itself being the show hide would be amazing and really cut down on duplicative variants (and thus memory usage too!). 🙏