LogicMachine Forum
change color switch - Printable Version

+- LogicMachine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Visu (https://forum.logicmachine.net/forumdisplay.php?fid=24)
+--- Thread: change color switch (/showthread.php?tid=6604)



change color switch - dezza@sdme.it - 28.11.2026

I need to change the color of a switch from JavaScript when the state of another field changes. 
Where can I find the widget specifications? 
Thanks a lot

Visu.on('widget-ready', 44, ({ widget }) => {
  const el = widget.getEl()
  if (el) {
    widget.listen('32/1/10', (value) => {
      el.querySelector('.switch')
      el.style.setProperty('--visu-widget-color', value ? 'red' : 'blue')
    })
  }
})