Skip to main content

Switch

The Switch widget is a slider-style toggle that flips between two states, on and off.
Use it when someone needs to pick one of two states, like turning a setting on or off.

Definition and role

The Switch widget is a control that switches between on and off as you slide the thumb along its track. Press it and the state toggles, running the onChanged action. Configure the state, whether it's enabled, the size, the corner radius, and the thumb size, plus the track and thumb colors for each state — on, off, and disabled.

  • Category: Contents
  • Default size: 38 × 22 (thumb (thumbSize) 14, corner radius (radius) 10)

Features

FeatureDescription
State toggleTap to toggle between on and off — this runs onChanged.
Enabled / disabledenable decides whether the switch is usable. A disabled switch is drawn in its own colors.
Size and shapeAdjust the size (width and height), corner radius (radius), and thumb size (thumbSize).
Colors per stateSet the track and thumb colors separately for the on, off, and disabled (on and off) states.

How to use

  1. Open the Contents category in the left widget palette.
  2. Drag and drop the Switch item onto the canvas.
  3. In the Properties panel on the right, set the initial state (value) and the colors you want.
  4. In onChanged, connect the logic or script to run when the state changes.

Properties

PropertyDescriptionDefaultValues / type
valueWhether the switch is on or offOff (false)true / false
enableWhether the switch is usable (enabled)On (true)true / false
SizeSwitch size — a grouped property that sets width and height togetherWidth 38, height 22Size (width and height, number in px)
thumbSizeThumb size14Number (px, minimum 14)
radiusTrack corner radius10Number (px)
activeTrackColorTrack color in the on state#9483FF (purple)Color
activeThumbColorThumb color in the on state#FFFFFF (white)Color
inactiveTrackColorTrack color in the off state#94999F (gray)Color
inactiveThumbColorThumb color in the off state#FFFFFF (white)Color
disabledTrackColorTrack color when disabled (off)#9F9F9FColor
disabledThumbColorThumb color when disabled (off)#737373Color
disabledActiveTrackColorTrack color when disabled (on)#9F9F9FColor
disabledActiveThumbColorThumb color when disabled (on)#6750A4Color

Notes and tips

tip

Set the on and off colors with activeTrackColor and inactiveTrackColor, and the disabled colors with the disabled... properties.

tip

thumbSize (the thumb size) has a minimum of 14. Adjust it together with the track height (height) so the thumb fits.

Learn more

tip

For the complete Widget Control (Property, Method, and Event) reference for scripting this widget, see Switch Widget Control.