Toggle Button
Toggle buttons switch between two persistent states, selected and unselected, for reversible actions such as enabling features or adding items to a selection.
@volvo-cars/css v3.3.1@volvo-cars/react-icons v4.0.2
A toggle button turns a reversible action on or off and shows the result immediately.
When to use
Section titled “When to use”- Turn a feature or setting on or off
- Add or remove items from a persistent list, such as favorites, bookmarks, or pins
- Apply or remove a single filter
- Switch a feature state immediately and reversibly
When not to use
Section titled “When not to use”- The action happens only once. Use a standard button.
- The action requires confirmation. Use a dialog.
- The choice is mutually exclusive. Use a radio group or tabs.
- Users choose from a set of filters. Use Chips.
- The button shows or hides content. Use a disclosure button with
aria-expanded, such as an Accordion. - The control is part of a form. Use a checkbox or switch.
- The action triggers navigation.
- The action is destructive, such as deleting or removing permanently.
Variants
Section titled “Variants”| Variant | Usage |
|---|---|
| Toggle Button | Comes with a backplate. Use it when more emphasis is needed. |
| Toggle Button Clear | Comes without a backplate. Use it when less emphasis is needed. Available in one size. |
Icon usage
Section titled “Icon usage”All toggle buttons support an icon before or after the label. Swap the icon to show the state. Icons improve recognition and speed up the interface. Use well-understood symbols only. Don’t use icons for decoration or icons that need explanation.
| Position | Usage |
|---|---|
| Before | Use a leading icon when it helps users recognize the action faster. The icon represents the action, such as + Add or − Remove. |
| After | Use a trailing icon when it shows the result of the action rather than the action itself. |
Content
Section titled “Content”- Keep labels short (1–2 words)
- Use sentence case
- Don’t truncate labels
- Keep the label the same in both states and swap the icon. If the label changes, such as Add and Added, keep both labels a similar length
- Provide an accessible label that describes the button’s purpose
- Use a familiar and meaningful icon that clearly communicates the action
Spacing and layout
Section titled “Spacing and layout”- Use consistent spacing around the toggle button and between adjacent controls
- Keep the same button size across similar controls
- Leave enough space between toggle buttons to prevent accidental activation
- Align toggle buttons with surrounding controls and content
- Keep the button’s size across selected, unselected, and loading states