Segmented button groups display a set of discrete buttons in a row as a single element.
When to use the segmented button groups
- Categorically related controls. For example, segmented buttons can be used as a switch between different views.
When to consider something else
- No clear relationship. Consider how placement and alternative structure of unrelated controls can improve usability over placing all actions in a group.
- If there are more than three buttons. Be mindful of how a long list of buttons might appear on small screens. An alternative type of control might be more suitable.
- Avoid ambiguity of current state. Make sure current states are clearly communicated and understood.
aria-labelto give the buttons a useful name. Some contexts may require additional context provided to screen readers.
- Use the
<button>element. Don't use
<a>because it's a link. Don't use
<span>because screen readers won't know it's a usable button.
- Don't mix differently-sized buttons (like a default button and a big button) in the same group.
- Use short, descriptive button labels to describe controls.
- Use default buttons as a current state and outline buttons as a non-current state. The segmented button group works with all button variants. However, you may need to create custom styles to distinguish state for some button variants.