Browse the docs
Inputs / Switch

Switch

The knob is a little face. It sleeps when off and wakes up when you flip it on.

Client componentWCAG AASince v0.1

Change every prop live in the playground.

Props

PropTypeDefaultWhat it does
aria-labelstringnoneAccessible name when there is no visible label.
checkedbooleanfalseControlled state.
childrenReactNodenoneThe label. Clicking it toggles the switch.
classNamestringnone—
color"ink" | "mint" | "tomato"mintTrack color when on.
defaultCheckedbooleanfalseUncontrolled initial state.
disabledbooleanfalse—
idstringnone—
namestringnone—
onCheckedChange(checked: boolean) => voidnone—
requiredbooleanfalse—
valuestringnone—

Use it well

DoUse it for settings that take effect right away.
Don'tUse it inside a form that needs a Save button. That's a Checkbox.

Accessibility

  • Built on the Radix Switch: role="switch" with aria-checked.
  • Clicking the label toggles it; Space and Enter work from the keyboard.
  • On and off also show in the knob's position and face, not only color.
Five stamps!

All aboard.

You took the whole tour. Here's Holo Pip, a foil sticker for riders who finish. It's in your playground tray now, for good.