Skip to content

Inputs

Toggle switch

Also calledswitchtoggleon/off switch

A two-state control that turns a setting on or off immediately, like a physical light switch.

How people describe it

  • “pill that slides left and right to turn something on or off”
  • “on off switch”
  • “little round knob on a track”

Good for

  • Settings that apply instantly
  • Enabling or disabling a feature

What your library calls it

LIBRARYCALLS IT
shadcn/uiSwitch
MUISwitch
Chakra UISwitch
MantineSwitch
Radix UISwitch

Accessibility checklist

  • Use the switch role with aria-checked
  • Support Space (and Enter) to toggle
  • Don't rely on color alone to show the state

Try it

Click or press Space. The state is announced as on or off.

Prompt

Add an on/off toggle switch with a label. Apply the change instantly.

~18 estimated prompt tokensDetailed: ~60 estimated prompt tokens

Rough estimate for prompt text only; actual counts vary by model and context.

<button role="switch" aria-checked="false" aria-label="Email notifications">
  <span class="knob"></span>
</button>

Used in

Explore website blueprints that use this component.