Skip to main content
Jul 11, 2023 11:02 AM UTC

Invert boolean variable for layer display

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

Nov 13, 2023 9:03 AM UTC

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
Dec 19, 2023 4:35 PM UTC

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
Jan 14, 2024 6:58 PM UTC

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
Jan 26, 2024 9:53 AM UTC

Adding my +1 to this.

elias_alegria
Feb 2, 2024 1:41 PM UTC

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

Ray19
New Member
Feb 19, 2024 10:09 PM UTC

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.

Mar 6, 2024 3:01 PM UTC

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.

Mar 6, 2024 3:29 PM UTC

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
Mar 25, 2024 1:41 PM UTC

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
Mar 29, 2024 8:30 PM UTC

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!). 🙏