ToggleSwitch

ToggleSwitch is used to immediately toggle a setting on or off.

Page navigation navigation

React
readyNot reviewed for a11y
Rails
readyNot reviewed for a11y

React examples

Default

Label

With a caption

Label
Switch caption

Custom size

A small toggle variant is available for dense layouts.

Default
Small

Status label after switch

Label

In a loading state

Display a loading indicator when waiting for an action to complete before toggling.

Label
Loading

Props

ToggleSwitch

NameRequiredDescription
aria-describedby
string
The id of the DOM node that describes the switch
aria-labelledby
Required
string
The id of the DOM node that labels the switch
defaultChecked
boolean
Uncontrolled - whether the switch is turned on
disabled
boolean
Whether the switch is ready for user input
loading
boolean
Whether the switch's value is being calculated
checked
boolean
Whether the switch is turned on
onChange
(on: boolean) => void
The callback that is called when the switch is toggled on or off
onClick
(e: MouseEvent) => void
The callback that is called when the switch is clicked
size
'small' | 'medium'
Size of the switch
statusLabelPosition
'start' | 'end'
<div>Whether the "on" and "off" labels should appear before or after the switch.</div> <div> <Text fontWeight="bold">This should only be changed when the switch's alignment needs to be adjusted.</Text> For example: It needs to be left-aligned because the label appears above it and the caption appears below it. </div>