Skip to content
TrademarkTrademark
Docs
Form Controls

Switch

Updated: October 11, 2026
View on GitHub

The Switch component provides a toggle control for binary states, featuring a sliding animation when toggled. It's commonly used for enabling or disabling features and settings.

State

Control the switch state with the checked prop. onToggle receives the state the switch moves to, so the setter can be passed straight in.

Uncontrolled

Leave out checked and the switch keeps its own state, starting from defaultChecked. onToggle still reports every change, and with a name the switch submits its value with a form.

Loading

Show a loading spinner while an action is being processed.

Disabled

Disable the switch to prevent user interaction.

Reversed

Place the switch on the right side of the label.

API reference

Type
Default
style
React.CSSProperties—
className
string—
checked
Whether it is on, controlled. Leave it out and the switch keeps its own state.
boolean—
defaultChecked
The starting state when `checked` is left out.
booleanfalse
loading
Show a spinner in the track while something resolves.
booleanfalse
name
Form field name.
string—
value
Form field value.
string—
disabled
Block interaction.
boolean—
reverse
Put the label before the switch instead of after it.
booleanfalse
ariaLabel
Label for a switch with no visible one.
stringToggle switch
onToggle
Called with the new state when it is flipped, by pointer or keyboard: true when it turns on.
(checked: boolean) => void—
label
ReactNode—
description
ReactNode—
iconButtonProps
Props forwarded to the icon button beside the label.
IconButtonProps—
…and every React.InputHTMLAttributes propinherited—
Edit this page on GitHub