Skip to content

Switch

<label class="label">
<input class="switch" type="checkbox" role="switch" name="airplane" />
Airplane mode
</label>

data-size="sm" gives the shorter track, for dense rows of settings.

A switch usually belongs at the trailing edge of a row, with the explanation on the other side.

Helps us find which features go unused.

SwitchCheckbox
Takes effectImmediatelyWhen the form is submitted
Reads asOn / offChecked / unchecked
Belongs inSettingsForms
Needs a Save buttonNoUsually

If the user has to press Save for it to count, it is a checkbox. A switch that only applies later is a broken promise.

Set dir="rtl" on the page or on any subtree — the track and thumb reverse with the reading direction. See the button page for a live example.

  • A switch needs a label like any control, wrapping it or with for.
  • The label says what it controls, not its state. “Airplane mode”, not “Airplane mode is on” — the state is announced from the control.
  • Do not put a switch behind a confirmation. Something that immediately does a dangerous thing wants a button and an alert dialog instead.