Design System
Forms

Switch

A setting that takes effect immediately, with no save step. If the change only applies when a form is submitted, use a checkbox instead.

Purpose

The distinction from Checkbox is when the change lands. A switch applies at once; a checkbox is collected and submitted with the rest of the form.

Example

States

On, off, and both disabled. A disabled switch keeps its position so the current setting stays readable.

Structure

PropertyValue
Track24 × 44px (h-6 w-11), fully rounded
Thumb20px (size-5), white, --shadow-1, travels 20px
On fill--primary · off fill --border
Focus2px --ring, offset 2px
Disabled50% opacity, not-allowed cursor

Best practices

Do

  • Reserve switches for settings that apply the moment they are flipped.
  • Label the switch with what it turns on — "Paperless statements", not "Enable/disable".
  • Put the label after the switch and link it with htmlFor, so clicking it toggles too.

Don't

  • Use a switch inside a form that ends in a Save button — that is a Checkbox.
  • Word labels as questions or negatives ("Don't notify me") — flipping one becomes a puzzle.
  • Rely on colour alone to signal state — the thumb position must carry it, and it does.

Accessibility & keyboard

  • Renders a real button with role="switch"; screen readers announce the on/off state from aria-checked.
  • Label the switch with what it turns on, not the current state, and pair it via htmlFor — clicking the label toggles the switch.
  • Focus shows a 2px --ring outline with offset — never remove it.
  • Keyboard: Space or Enter toggles; Tab moves focus.

Props

Switch is a styled re-export of the Radix Switch root — it takes checked / onCheckedChange for controlled use, defaultChecked for uncontrolled, plus disabled, required, name and value for forms. See the Storybook prop tables for the full generated API.

On this page