Skip to main content

Switch

The Switch component is designed for capturing binary choices with clear visual indicators for 'On' and 'Off' states. It offers customization options for labels and is ideal for simple on/off decisions, with accessibility considerations for all users.

Example of a switch component.

Switch Properties

Component Properties

PropertyDescription
LabelThe label to be displayed besides the switch
Label Text StyleChanges the style (font, size, etc.) of the switch's label text. Configure styles in the Typography settings
Label Text ColorChanges the color of the switch's label text
Label PositionThe position of the label, options are "Left" or "Right"
Default StateWhether the switch is toggled on by default, values are a boolean
RequiredRequires that the switch is toggled on for form submission, values are a boolean
VisibleControls the visibility of the component, values are a boolean
DisabledDisables user interaction with this component, values are a boolean

Reference Properties

Properties can be accessed from other frontend components and backend APIs by adding the name of the Switch component, and dot referencing the property. For a Switch named Switch1:

PropertyDescription
Switch1.isDisabledReturns the boolean value of the switch's disabled state (True, if it is disabled)
Switch1.isRequiredReturns the boolean value of if the switch is require (True, if it is required)
Switch1.isVisibleReturns the boolean value of the switch's visibility (True, if it is visible)
Switch1.isToggledOnReturns the switch's state (True, if it is toggled on)
Switch1.labelReturns the switch's label as a string
Switch1.labelPositionReturns the switch's label position as a string

Events

The following events are triggered by user interactions with Switch components. Use event handlers to trigger actions in response to user events.

Table Reference PropertyDescription
onSwitchChangeTriggers an action when the switch state is changed