Components
Switch
On/off toggle for settings that apply immediately: a 30×18 pill track with a white knob.
Usage
Use it to:
- turn a setting on or off with an immediate effect
- settings lists and preference panels
Don’t use it to:
- choices that are submitted later with a form (use Checkbox)
- choosing between two named options (use RadioGroup or SegmentedControl)
Installation
Install the package (React 19):
terminal
terminal
terminal
Import the styles once, in your app entry or root layout:
/src/main.tsx
Use it anywhere inside your app's <Theme> (see Installation):
/src/SwitchExample.tsx
Examples
States
Size
sm (24×14) for dense rows.
Settings row
Lock page
Prevent accidental edits.
Dark theme
API Reference
Switch
Radix Switch (a <button role="switch">); supports all of its props. Adds:
| Prop | Type | Default |
|---|---|---|
checked | boolean | |
defaultChecked | boolean | false |
onCheckedChange | (checked: boolean) => void | |
label | ReactNode | |
invalid | boolean | false |
size | "sm""md" | "md" |
disabled | boolean | false |
name | string | |
required | boolean | false |
className | string |
Accessibility
Tabfocuses the switch;SpaceandEntertoggle it. State is announced throughrole="switch"+aria-checked.- Name it with
label,aria-labeloraria-labelledby. - The button is 24px tall on touch screens; the track keeps its size. The knob does not animate with reduced motion.
© 2026 Motion. Internal documentation.