Live demo
Demo source
Use a toggle for a setting that takes effect as soon as it changes, such as notifications or dark mode. If a change only applies after saving, or people choose several options from a list, use a checkbox instead.
Anatomy
A toggle with three callouts: 1 marks the label Label, 2 the description below it, and 3 the switch to the right, shown off.
- Label names the setting.
- Description (optional) explains the effect, such as "You will receive email updates for new messages."
- Switch shows whether the setting is on or off. Space toggles it from the keyboard.
States and placement
A toggle is on (checked) or off. Set labelPlacement to before to put the
label first, as the design guidelines recommend, so people read the setting
before they reach the switch. A disabled toggle cannot be used, and a
read-only one shows its state without allowing changes. Hover and keyboard
focus provide feedback on an enabled switch. labelPlacement="after" puts
the label on the other side when the layout needs it. error and success
change its colour; pair them with text that explains why.
Themes
The design includes Spark and Ocean appearances. Use the page's theme and mode controls to compare the live examples; retain the same labels, states and validation messages in each theme.
Guidelines
- Use a short label that names the setting, such as "Email notifications".
- Apply the change immediately; don't wait for a save button.
- Match the default to what people expect: opt-in settings start off.
- Keep the label close to its switch.