Skip to content

Toggle Switch ui-switch

Try Demo

Adds a toggle switch to the user interface.

Properties

PropDynamicDescription
GroupDefines which group of the UI Dashboard this widget will render in.
SizeControls the width of the button with respect to the parent group. Maximum value is the width of the group.
LabelThe text shown within the button. Html content is allowed.
LayoutDefines how the label and the switch are arranged. Users can choose between different layout options such as aligning elements to the left, left reversed, spread evenly or spread evenly but in reversed order.
ClickableThe clickable area (which will result in the switch toggling).
On IconIf provided, this Material Design icon will replace the default switch when in "on" state. No need to include the mdi prefix.
Off IconIf provided, this Material Design icon will replace the default switch when in "off" state. No need to include the mdi prefix.
On ColorIf provided with a icons, this colour is used for the icon when in "on" state
Off ColorIf provided with a icons, this colour is used for the icon when in "off" state
PassthroughIf enabled, the widget will pass through the input message to the output.
IndicatorOnly available when "Passthrough" is set to false. Defines whether the switch shows the status of the output, or any provided input via msg.payload.
On PayloadThe type & value to output in msg.payload when the switch is turned on.
Off PayloadThe type & value to output in msg.payload when the switch is turned off.

Dynamic Properties

Dynamic properties are those that can be overriden at runtime by sending a particular msg to the node.

Where appropriate, the underlying values set within Node-RED will be overriden by the values set in the received messages.

PropPayloadStructuresExample Values
Classmsg.ui_update.classString
Labelmsg.ui_update.labelBoolean
Layoutmsg.ui_update.layoutString
Clickablemsg.ui_update.clickableAreaString
Passthroughmsg.ui_update.passthruBoolean
Indicatormsg.ui_update.decoupleBoolean
On Colormsg.ui_update.oncolorString
Off Colormsg.ui_update.offcolorString
On Iconmsg.ui_update.oniconString
Off Iconmsg.ui_update.officonString

Controls

msg.ExampleDescription
enabledtrue | falseAllow control over whether or not the switch can be toggled via the UI.

Example

Example of a Toggle SwitchExample of rendered switches in a Dashboard.