Styles

You can also set the style of an object. Let's assume we want to make an element red if the value is too low. The code would look like this:

let screen = qux.getScreen('Screen')

let widget = screen.getWidget('Element')

if (data.valueA * 1 < 100) {

    widget.setStyle({color: 'red'})  

} else {

    widget.setStyle({color: 'black'})  

}

The script uses the setStyle() method to set a new style. You simply need to pass a JavaScript object of key-value pairs. The keys are the CSS property you want to change, the value is the corresponding CSS value. You can also pass several properties in one call.

Flowrabbit Scripts follows the standard JavaScript way of set CSS styles. For instance, the "border-top-color" would have the key "borderTopColor"

Was this article helpful?

Script Basics & Intro