Skip to main content
Solved

How do I set a variable when clicking a component, while also changing its variant?

  • November 21, 2023
  • 4 replies
  • 1467 views

Francois_Jordaan1

I have a checkbox component that changes to a “checked” variant when clicked. When I click on an instance of this component, I want to set a variable. But when I add the “on click” interaction to set the variable, it overrides the component interaction, so the checkbox doesn’t get checked anymore.

Is this possible to do in Figma?

Best answer by Francois_Jordaan1

It looks like I can use the “While pressing” trigger to retain the component interaction, and also set the variable. I don’t know why this works, but it seems to solve my problem.

View original

4 replies

Francois_Jordaan1

There is an imperfect solution. I can add an extra “Change to” action on click, and change it to the “Checked” variant. This works, although it forces me to replicate an interaction that already exists on the component, only to set a variable. It also means I cannot click on it again to un-check the checkbox.


MaxZuman
  • 26 replies
  • November 21, 2023

set the variable change on “onMouseUp” trigger next to onClick


Francois_Jordaan1

@MaxZuman That doesn’t work, unfortunately. It still deactivates the inherited component interaction, so the checkbox doesn’t get checked.


Francois_Jordaan1

It looks like I can use the “While pressing” trigger to retain the component interaction, and also set the variable. I don’t know why this works, but it seems to solve my problem.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings