Skip to main content
Lisa8
December 8, 2023
Question

[solved] Is there a way to set variable and change to different variant of a component at the same time?

  • December 8, 2023
  • 3 replies
  • 1878 views

Dear Figma community,

I’d like to do two actions on click of a checkbox:

  1. set a variable to increase a counter
  2. change the component variant to a different variant that has a checked checkbox.

Just looking at the interface Figma seems to allow me to do this and add the change to. However when I try to change the status from “default” to “selected”, it automatically switches back after I select “selected”. Why could this be? Does anyone have an idea?

Thank you for your help!

Update: I got it to work by removing and adding it back a few times. Not sure what happened there.

This topic has been closed for replies.

3 replies

Max_Humberstone
December 13, 2023

How did you get this to work? I’ve tried deleting and adding many times but it just keeps switching back to the current variant.

Lisa8
Lisa8Author
December 13, 2023

I frankly don’t know, I tried out many many times of removing and adding back and at some point it worked. I think it also had to do with the order in which I added but just assumptions.

itm
New Member
March 10, 2025

I’ve found order matters. Some actions cause later ones to be ignored. My best practices though I’m not sure if it’s a foolproof solution is to always have variables set before I do anything else (open overlays, navigate to, etc.)