Change a CLASS based on a variable?

Is there a way to change a class based on a variable? So, if variable = true then use this class, if variable = false - then use this class?

Hi, you can create a state, bind a condition, and select a different class for each state :slight_smile:

Hey Alexis - I can’t figure out how to “select a different class for each state” … any further guidance most appreciated. The AI Co-Pilot says “I don’t know” :wink:

Select a state, then select a class. Then select another state and select another class.

Now, if you toggle the state your class should toggle too

Okay, that works. Thx!

I don’t suppose there is a way to do this globally? Or more efficiently than adding that to every element?

In other words - change ALL INSTANCES of one class to another class based on a state change?

If your changes are based on global variable, what you can do is doing the opposite: having the property inside the class being dynamic, and always apply the same class. Formula are compatible with classes.

So for example, you could have a property color bind to a formula depending on a theme, and save this inside a class. Then each element with that class will have the behaviour of changing color depending on the theme.

2 Likes

Okay - this is exactly what I am going for. I’ll give it try. Thx!!

That was easy … and awesome.

1 Like