Skip to content

role switch

Switch draft v0.1.0

Turns a setting on or off, with immediate effect.

A switch is a binary control for a setting that applies as soon as it is flipped: notifications on or off, dark mode, airplane mode. It has two values only, on and off, shown by the position of its thumb and the fill of its track. A choice that is saved later with a form, or that may be partially on, is a Checkbox.

Guidelines

From apps/docs/content/components/switch.md

Overview

A switch flips a setting between on and off, and the change applies as soon as it is made: no Save button follows. The track and the thumb show the state together: outlined with the thumb at the start when off, filled with the thumb at the end when on. Assistive technology announces it as a switch, on or off, which is why it must only be used for settings that really behave that way.

This page applies to every platform. Where a platform differs, the difference sits under a sub-heading named after it (Web, iOS, Android, Desktop); everything else holds everywhere.

When to use

  • A setting with two opposite states that takes effect immediately: notifications, dark mode, a feature flag, airplane mode.
  • Lists of settings where each row is one independent on / off choice.

When not to use

  • The value is saved with a form, when people submit it. Use a Checkbox: people expect a switch to act at once.
  • The choice can be partially on, or stands for a group of options. Use a Checkbox, which has an indeterminate state.
  • Choosing between several values. Use a Radio group or a Select.

Sizes

Size Use for
Small Dense lists and table rows, with a 14 px label. The track is under the 24 px minimum target, so the label must stay part of the target.
Medium Settings pages, the default, with a 16 px label and a 24 px high track.

Track, thumb, label and description scale together. The exact values are tokens (Tokens tab).

Label and description

The label names the setting as the thing that is on when the switch is on (Email notifications, not Enable notifications?). It is the accessible name and activating it flips the switch. The description adds what the setting does when the label is not enough. Never write On or Off next to the switch: the state is announced and shown by the thumb.

States

State How it happens What changes
Default Resting, off. An outlined track, thumb at the start edge.
Hover A pointer rests over the track or the label. Needs a pointing device: there is no hover on touch. The off track takes a light tint. An on switch does not change.
Focus visible Keyboard focus on the track. The shared focus ring appears outside the track. Pointer focus shows no ring.
Checked checked property (on). The track fills with the brand color and the thumb moves to the end edge.
Disabled disabled property. Track, thumb, label and description drop to the shared disabled colors, on or off.

Content

  • Name the setting as what is on when the switch is on: Email notifications, Dark mode.
  • Sentence case, no trailing punctuation, one line.
  • Consequences go to the description: Ask for a code from your authenticator app at sign-in.

Accessibility

The Specification tab lists the full accessibility contract, grouped into what holds on every platform and what is specific to one. Each statement there links the source it comes from. This section explains the decisions behind it.

Web

iOS

Android

  • Checkbox (a value saved with a form, or a partially on group)
  • Radio group (one choice among several)