Changing a switch's colors according to its own value

There's a little example for incrementing a variable widget with a button in Feature demo : property inheritance, scripting, clones (scripting.json), seems like a good starting point.