### Mapping variable changes to widget states #### Introduction Consider a simple button: ```html ``` Now, if you want to link a variable's value to a widget property like "state", the interface designer wizard will create a binding element for you which set's the widget property "state" to the variables value: ```html ``` Every time the variable changes, it will set the widget property "state" to the variable's value. Now lets add some states which add CSS classes: ```html ``` As soon the variable's value is 1, it will activate the state with the name "1". In this case, it's adding the CSS class "state_1" to the button. #### Rejecting state selection for variable changes There are moments where you don't want to apply a state when the variable changes. This can be done with the "accept" function. Such expression can be defined as part of the binding element to our variable. ```html ``` #### Transforming variable value to another state name Sometimes a variable may not have very friendly values or at least values which can't be used as state name. In this case you can "transform" or map a variable value to a state name. For this you can define a transform function: For example, we want to activate the state named "another state" when our variable value is "foo"; ```html ```