Switch
A switch turns one setting on or off, and the change applies at once. Nothing waits for a Save button.
What it is
When to use it
Use a switch for a setting that takes effect as soon as it is flipped, such as whether a job ad accepts applications.
If the change waits for a Save button, use a checkbox: a switch in that panel looks saved the moment it is flipped, and it is not. For a choice between more than two states, use radio buttons or a segmented control. On a toolbar, a toggle button such as Assigned to me does the same job in less room.
Anatomy
Off is a gray track with the white knob at the start. On fills the track with brand blue and moves the knob to the end, so the state shows in position as well as in color.
- Track
- 40 by 24 px, fully rounded, no edge
- --radius-full
- Off track
- gray
- On track
- brand blue
- --brand-blue
- Knob
- 20 px, white, 2 px from the edge
- Knob travel
- 16 px
- Label
- 14 px on a 20 px line
- --text
- Description
- 13 px on an 18 px line
- --text-muted
- Settings row
- at least 44 px high
States
A switch does not change under the pointer. While a change saves, it already shows the new position.
- Off
- On
- Focus
- Saving
- Disabled off
- Disabled on
- Off
- On
- Focus
- Saving
- Disabled off
- Disabled on
- Focus ring
- 2 px, 2 px outside the track
- --focus-ring
- Saving
- the new position at once, busy until the save returns
- Disabled
- the whole switch at half strength, in place
Behavior
The knob slides in 150 milliseconds while the track fills. With reduced motion, the switch changes state without sliding.
The change saves as soon as it is made, and the new position shows straight away, even on a slow connection. If saving fails, the switch goes back to where it was and a message under the row says what went wrong.
Tab reaches the switch and Space or Enter flips it. A click on the label flips it too.
Where the label goes
In a list of settings, the label starts the row and the switch ends it. Among other controls, such as the options of an offer to a candidate, the switch comes first and its label follows.
A switch without words of its own, such as one in each row of a list of board admins, takes a name that includes the row: Board admin, Ana Horvat.
- In a list of settings
- Among other controls
Writing the label
Name the setting with a noun or a short phrase that says what on means: Show the salary, Ask for a signature. Never name the opposite, such as Hide the salary: switching it on would take something away.
Leave out Turn on and Enable, since the switch already says that, and do not write the label as a question.