Skip navigation
Swap variant instances between modes in Figma using boolean variables.
0:00 / 3:45

Swap variant instances between modes in Figma using boolean variables.

MDS

89K followers

Visit on X
101 likesDownloadOriginal post

34,184 views

Swap variant instances between modes in Figma using boolean variables. 🤔 Doing it right, or missing something?

16 Comments

Comments from the original post on X (Twitter)

  • Johan Netzler's profile picture

    @jnetzlr

    @figma Here’s another way of solving this. Maybe ✌️

    24 likes

  • MDS's profile picture

    @mds

    @figma Whoa, didn’t realize you could use string variables like that. Thanks!

    3 likes

  • Catherine's profile picture

    @ktryndschrs

    @figma From my understanding, it is not possible at the moment… The variable can be linked to a value within an instance, but not directly inside a component… Here is a test within a frame :

    2 likes

  • Kish's profile picture

    @IAmByDesign1

    @figma Set the mode on the section when the instance is inside the section and not the shape

    1 like

  • MDS's profile picture

    @mds

    @figma Ah yeah, I think I set the mode before I created the boolean variable. Seems like it should work even if one came before the other.

    2 likes

  • Maxim Leyzerovich's profile picture

    @round

    @figma this is the true power

    1 like

  • Alex Yakir's profile picture

    @alexyakir

    @figma I love that. If you make a Shape variable numeric with light mode value 0 and dark mode value 100, and then apply this variable to the corner radius, will the shape trigger as you want?

    1 like

  • MDS's profile picture

    @mds

    @figma Yeah that would probably work in this scenario, but I'm trying specifically to get the instance swap to work for an actual design I'm working on.

    1 like

  • Alex Yakir's profile picture

    @alexyakir

    @figma Oh I see! Try it here, it's triggering without manually setting auto mode:

  • Alex Yakir's profile picture

    @alexyakir

    @figma plus it follows your design pattern

  • Mihai Marcu's profile picture

    @designmistik

    @figma @mds you need to use in the boolean of the variant true and false this will result in the boolean variable to work correctly. I won't work with on/off or yes/no.

  • Vikas Raj Yadav ˎˊ˗'s profile picture

    @Vraj247

    @figma This is cool.

  • Ankit Ruhela's profile picture

    @anktrhla

    @figma Round corner variables I think is what you need there. I may be wrong, just starting to play around with it.

  • MDS's profile picture

    @mds

    @figma I’m trying to specifically nail down instance swap for a bigger cause in an actual project.

  • Ankit Ruhela's profile picture

    @anktrhla

    @figma Instead of using a Boolean variable for Shape, try using Number variable for Radius. Set radius to 0 for light mode and 200 for dark mode. Then, where you change border radius, the little variable hexagon will popup when you hover, assign that to Radius variable. 🙌🏼

  • Ankit Ruhela's profile picture

    @anktrhla

    @figma Here’s a quick demo, hope it helps