search⌘K

Switch

Last Updated: September 2026

Switches toggle an immediate on/off setting with a track affordance.

Anatomy

link
Dotted grid scale: 8px
  1. 1Track
  2. 2Thumb
  3. 3External label

Variants

link

Off

Unchecked until toggled.

On

defaultChecked for an enabled starting state.

Disabled

disabled prevents toggling in both on and off states.

Sizes

link

Switches support 2 sizes: S and M.

Line spacing scale: 8px
20px
32px

Usage Guidelines

link

When to use

  • •For immediate on/off settings that take effect without a submit button.
  • •When a track affordance better communicates binary state than a checkbox.
  • •In settings panels and preference rows.

When not to use

  • •For form agreement / multi-select — use Checkbox.
  • •For choosing among several options — use Select or Segmented Control.
  • •For destructive one-shot actions — use Button with confirmation.
checkDo

Place a visible label beside the switch and mirror it with aria-label.

closeDon't

Don't ship a bare Switch without an accessible name.

checkDo

Use Switch when toggling applies immediately (preferences, visibility).

closeDon't

Don't use Switch for selecting items in a list — use Checkbox.

Behaviors

link

Value model

  • •Uncontrolled: defaultChecked.
  • •Controlled: checked + onCheckedChange.
  • •Built on Base UI Switch Root.

Size

  • •size="md" (default) — larger track and thumb.
  • •size="sm" — compact for dense settings lists.

Styling constraints

  • •className is omitted from the public props — do not pass className.
  • •There is no built-in label; compose adjacent text yourself.

Content Guidelines

link

Labels

  • •Name the setting, not the state (“Notifications”, not “On/Off”).
  • •Keep labels parallel across a settings list.

Feedback

  • •Apply the change immediately — don't pair a Switch with a Save button.
  • •If the toggle can fail, surface the result with a Toast rather than reverting silently.

Accessibility

link

Text & Labels

  • •Always provide aria-label or associate a visible <label htmlFor=…>.
  • •Visible text should match the accessible name.

ARIA attributes

  • •Role and checked state come from Base UI Switch.
  • •disabled is exposed and removes pointer interaction.

Keyboard Support

  • •Tab → focus the switch.
  • •Space / Enter → toggle.

WCAG Compliance Standards

FAQs

link

Does Switch accept a label prop?

No. Compose adjacent text and set aria-label (or wire htmlFor to the control id).

What sizes exist?

sm and md (default). Pick sm for dense preference rows.

Can I pass className?

No — className is omitted from SwitchProps. Style via layout wrappers instead.

link