Skip to main content
Version: 2027.02 Beta
View as Markdown

Perspective - Toggle Switch

Component Palette Icon:

Description​

The Toggle Switch represents a bit: on (selected) or off (not selected). By default, when the switch is selected the color is blue. It is gray when it is not selected. Logically, this component is very similar to the Checkbox component.

The Toggle Switch component has three pre-configured variants:

  • No Text: Default layout with no text.
  • Text Right: Layout with text on the right of the Toggle Switch.
  • Text Left: Layout with text on the left of the Toggle Switch.

Properties​

Most Properties have binding options. For more information on Bindings, see Types of Bindings in Perspective. This section only documents the Props Category of properties. The other Categories are described on the Perspective Component Properties page.

NameDescriptionProperty Type
selectedThe selected state of the Toggle Switch.value: boolean
labelSettings for the label for the Toggle Switch.
  • text: Text for the Toggle Switch. Text can also be entered directly by deep selecting the Toggle Switch component, which enables inline editing. Changes are immediately reflected in the text property field. Value is string.
  • position: Text position relative to the Toggle Switch: right or left. Value is boolean.
  • style: Modify text style using the style properties. Full menu of style options is available for text, background, margin and padding, border, shape and miscellaneous. You can also specify a style class.
object
colorColor settings for the Toggle Switch for each state it is in. Colors can be chosen from a color wheel, color palette, or entered as RGB or HSL values. See the Color Selector page for more information.
  • selected: Color of the Toggle Switch when selected (on).
  • unselected: Color of the Toggle Switch when unselected (off).
  • disabled: Color of the Toggle Switch when disabled by the enabled property.
    • selected: Color of the Toggle Switch when selected (on) and disabled.
    • unselected: Color of the Toggle Switch when unselected (off) and disabled.
object
enabledWhether the user should be allowed to alter the Toggle Switch's selected state. Default is true.

Note: If the component is disabled, scripts can still run on the component. For example, if you add a script action to the onClick event, the script will fire when the user clicks on the Toggle Switch.
value: boolean
styleSets a style for this component. Full menu of style options is available for text, background, margin and padding, border, shape and miscellaneous. You can also specify a style class.object

Component Scripts and Events​

Further component interaction and functionality can be configured for all components through scripting and event actions. Right-click on the component or select Components from the Designer menubar to access the configuration popups for both of these options:

  • Configure Events: Accesses the Event Configuration popup where you can configure actions to run in response to events to make the component dynamic. The Events Configurations page shows how to configure events and actions on a Perspective component.

  • Configure Scripts: Accesses the Script Configuration popup where custom methods and message handlers can be added. The Scripting in Perspective section details scripting fundamentals, creating custom methods, and using message handlers.

Example​

Image above shows both selected and deselected positions for the following properties.

PropertyValue
props.label.textOff / On
props.label.positionleft
props.color.selected#FF0000
props.color.unselected#8AFF8A