UI Toggle Button Value Data Binding

I have a quick question about the toggle button in the UI builder. It doesn’t appear to have a “Value Logic” handler like other input buttons do. I also saw in another support thread that it’s default state won’t be bound anywhere automatically.

Does that mean that when I used a toggle I need to set up an On Mount event that will assign a property to the default value, then use the On Change handler to modify that property when the toggle is changed?

Since the toggle essentially takes a true/false state I am surprised that I can’t directly bind this to a value like with other inputs. Maybe I’m missing something obvious though.

Thanks for the help!

1 Like

Hello @James_Hereford ,
Thank you for contacting us, we are always happy to help.
Such a handler exists, it is called “Checked State Logic”

You can also set a default value in the tab (USER INTERFACE) which will have a lower priority compared to the handler and date binding.


Thanks Sergey. I do see how I am able to control the toggle state using that handler. I just want to confirm though - is there no way to ‘read’ the current state of the UI toggle (including the starting state) and save that into a variable?

It seems like in your example I would have needed to create the property ‘isChecked’ in Page Data before being able to use it in the Checked State Logic handler. Is that correct?


Hi @James_Hereford

yes, specifying initial data in a DataModel will work
another approach is using the “Checking” option in the UI Settings and data-binding for the “Checked State Logic”, if it’s enabled in the UI Settings and it has data-binding it sets the value on the first render


Ahh, that makes sense. Thanks so much for clarifying!