Toggle Switch allows users to toggle a boolean selection between states instantly. There is always a default selection for switches.
On this page
Toggle switch labels are required and should be short, clear and descriptive. It should be easy for the users to understand what they are activating.
Avoid ending labels in punctuation, colons or commas.
Label is positioned left of the toggle control because its necessary for the user to read first then take an action of activating or deactivating.
Enroll your mobile number to receive account alerts.
| Radio | Checkbox | Segmented Control | Switch | |
|---|---|---|---|---|
| How many choices does the user have? | At least two | At least one | At least two (this or that) | Only two (on or off) |
| Can there only be one option selected? | Yes | No | Yes | Yes |
| Is it possible for a user to leave the choice unselected? | Yes, but this is typically not ideal | Yes | No—one option is always selected | No—a switch has default state on or off |
| Does the choice require submission in order to take effect? | Typically yes | Typically yes, for Terms and Conditions | No | No |
Switches are best used for communicating activation such as on/off states, while checkboxes are best used for communicating selection and may require a submission to save selection. Toggle Switch should never require users to press a button to apply the settings. Toggle switches can’t have an error state compared to checkbox.
Note that the toggle switch is used mostly commonly with system settings and preferences and not used in forms where checkboxes and radios are commonly found.
Toggle switches are binary options, not opposing ones. A binary option represents a single state that is either on or off.
Opposing options are two separate states that are opposite but related to different user tasks. Segmented Control offers alternate view of related content.
To make understanding the state of the switch easier for users with visual or cognitive disabilities, a text equivalent of the state (on or off) and icon on the control is displayed in toggle switch as a state indicator.
NOTE: To prevent redundant announcement of the state by screen readers, the text indicators of state are hidden from assistive technologies with aria-hidden.
Text Indicator is optional and it is used within toggle control. Text used should be short, simple, and easy to understand the action being made such as on/off, active/inactive, or show/hide. Text indicator can be changed based on the user and context around the toggle switch.
Icon Indicator is optional and it is used within toggle control to visually emphasize the selected state. Icon used should be simple, with well known visual metaphors, such as check for active/on, close for inactive/off. Icons can be changed but be mindful on what that icon signifies and it should represent with the toggle switch label.
Try to avoid using disabled state when possible, opting for enabled toggle switch or no toggle switch and an informative alternative on why its disabled. If you do choose to use a disable toggle switch, use aria-disabled=true instead of disabled, so it’s announced to screen reader users.
Disabled elements are visible, but not always focusable. They are not announced to screen readers using tab, and can only be found if your users go looking for them.When the label is too long for the horizontal space available, it wraps to form another line.
When it is stacked as a list with shot or long length of label and hint text, toggle control is always aligned top.
Connect with the DLS Team on Slack or by email.
Check out additional resources.