Within a toggle button group, only one option can be selected at a time. Selecting one option deselects all others.
Use a toggle button group as a switch between different views. For example, use the component to allow users to switch between a list view and gallery view.
- Group items within a toggle button group that are related and have a logical connection to each other
- Think about whether your toggle button group needs text and an icon, text only, or an icon only
- Use short and concise text for the labels (if applicable)
- Place the toggle button group in close proximity (ideally just above) to the area it controls
- Don't group items that aren't clearly related
- Don't use an icon-only toggle if the actions aren't clearly understood
- Don't use a toggle button group if there are more than three options
- Avoid wrapping the toggle button group onto more than a single row.
If using labels, they should be concise and descriptive, using no more than three words.
Indicates that the user can interact with the button.
Indicates that the button is selected.
Indicates that the user is unable to interact with the button.
1.3.1 Info and Relationships A
There is a
role="group"attribute on the parent elementIf the toggle button group is part of a toolbar use
role="toolbar"
Use the semantic
<button>on all grouped elements under the parent elementIf the button needs additional information in order to be understood by assistive technologies, use an
aria-labelattribute to convey this information
- Reads: "Button name (or aria-label), button"
- Tab: advances to the next element
- Shift + Tab: goes to the previous element
- Enter or Space: activates the element in focus