A simple example of a button that has two states and changes colour/text and icon based on those two states
[{"id":"b9a70965.13e138","type":"ui_button","z":"d511095d.512808","name":"","group":"c070ecdb.6d5ce","order":0,"width":"0","height":"0","passthru":false,"label":"{{payload}}","color":"","bgcolor":"{{colour}}","icon":"","payload":"press","payloadType":"str","topic":"","x":590,"y":615,"wires":[["48aaee20.8d9e1"]]},{"id":"5cc84101.ac6d9","type":"change","z":"d511095d.512808","name":"","rules":[{"t":"set","p":"colour","pt":"msg","to":"green","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"<i class=\"fa fa-rotate-90 fa-folder-open-o\"></i> OPEN","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":570,"wires":[["b9a70965.13e138"]]},{"id":"329e773b.0fdcb8","type":"inject","z":"d511095d.512808","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"","x":215,"y":570,"wires":[["bc5a70e.6f6a29"]]},{"id":"48aaee20.8d9e1","type":"function","z":"d511095d.512808","name":"state","func":"var state = context.state || false;\nstate = !state;\ncontext.state = state;\nif (state) { return [msg,null]; }\nelse { return [null,msg]; }\n","outputs":2,"noerr":0,"x":215,"y":615,"wires":[["5cc84101.ac6d9"],["bc5a70e.6f6a29"]]},{"id":"bc5a70e.6f6a29","type":"change","z":"d511095d.512808","name":"","rules":[{"t":"set","p":"colour","pt":"msg","to":"red","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"<i class=\"fa fa-rotate-90 fa-folder-o\"></i> Closed","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":615,"wires":[["b9a70965.13e138"]]},{"id":"c070ecdb.6d5ce","type":"ui_group","z":"d511095d.512808","name":"Click","tab":"7d974e73.cf8f9","order":1,"disp":true,"width":"5"},{"id":"7d974e73.cf8f9","type":"ui_tab","z":"d511095d.512808","name":"Home","icon":"link","order":1}]
And similarly for the switch widget
[{"id":"e5b337f.ddf04c8","type":"inject","z":"d511095d.512808","name":"","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":true,"onceDelay":"","x":200,"y":705,"wires":[["dcbbf896.32fb28"]]},{"id":"695a1cfd.452994","type":"ui_switch","z":"d511095d.512808","name":"","label":"{{label}}","group":"ccbdd82d.3c19b8","order":0,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"fa-sun-o","oncolor":"red","offvalue":"false","offvalueType":"bool","officon":"fa-cloud","offcolor":"grey","x":590,"y":705,"wires":[["7926b21b.c61b6c"]]},{"id":"7926b21b.c61b6c","type":"delay","z":"d511095d.512808","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":600,"y":750,"wires":[["b797b90b.f62108"]]},{"id":"dcbbf896.32fb28","type":"change","z":"d511095d.512808","name":"","rules":[{"t":"set","p":"label","pt":"msg","to":"click for on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":750,"wires":[["695a1cfd.452994"]]},{"id":"b797b90b.f62108","type":"switch","z":"d511095d.512808","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":200,"y":750,"wires":[["d3cd1f2c.519bd"],["dcbbf896.32fb28"]]},{"id":"d3cd1f2c.519bd","type":"change","z":"d511095d.512808","name":"","rules":[{"t":"set","p":"label","pt":"msg","to":"now turn off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":705,"wires":[["695a1cfd.452994"]]},{"id":"ccbdd82d.3c19b8","type":"ui_group","z":"","name":"Default","tab":"7d974e73.cf8f9","order":3,"disp":true,"width":"6","collapse":false},{"id":"7d974e73.cf8f9","type":"ui_tab","z":"d511095d.512808","name":"Home","icon":"link","order":1}]