An official website of the United States government
Here’s how you know
Official websites use .gov A
.gov website belongs to an official government
organization in the United States.
Secure .gov websites use HTTPS A
lock (
) or https:// means you’ve safely connected to
the .gov website. Share sensitive information only on official,
secure websites.
Actions have a contextual relationship. For example, the default button group can be used when a form has both a primary and alternative action.
Stepping through linear content. Buttons in a button group can be used for directional navigation and actions (e.g., “Back,” “Next,” “Continue,” “Skip,” “Cancel.”).
When to consider something else
If actions are not related. Consider how placement and alternative structure of unrelated actions can improve usability over placing all actions in a group.
When mixing destructive and non-destructive actions. This can lead to input mistakes.
Linking to content. Buttons in button groups should not be used when text links would be simpler and more contextually appropriate. Grouped buttons such as “Next” and “Previous” are acceptable when content is organized sequentially.
Usability guidance
Avoid burden of choice. Try not to present the user with too many options.
Accessibility guidance
Convey relationship. If not using a list element, give the parent element role="group" in order to convey to screen readers that actions are part of a group. If using as part of a toolbar, use role="toolbar".
Using the default button group
Buttons inside of a button group follow the same guidelines as the button component.
Button groups support any style and size.
Because the button group uses flexbox, there are several ways to modify how the default button group is displayed.
The default button group will display as a column on smaller screen sizes. To override this behavior and display buttons in a row for all screen sizes, use the flex-row utility.
On smaller screens, the first button in the source order will appear at the top of column. You can change this behavior using the order utility. The order utility includes responsive advanced settings that allow it to target specific screen sizes.
Instead of each button appearing on the left-hand side on larger screens (or if you used flex-row), you can use flex-justify to justify the buttons
Package
Package usage:@forward "usa-button-group";
Dependencies: usa-button
Segmented button group
Segmented button groups display a set of discrete buttons in a row as a single element.
Guidance
When to use the segmented button group
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.
Usability guidance
Avoid ambiguity of current state. Make sure current states are clearly communicated and understood.
Accessibility guidance
Convey relationship. If not using a list element, give the parent element role="group" in order to convey to screen readers that actions are part of a group. If using as part of a toolbar, use role="toolbar".
Use aria-label to give the buttons a useful name. Some contexts may require additional context provided to screen readers.
Use the <button type="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.
Using the segmented button group
Buttons inside of a button group follow the same guidelines as the button component.
Button groups support any style and size.
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.
Package
Package usage:@forward "usa-button-group";
Dependencies: usa-button
Latest updates
Meaningful code and guidance updates are listed in the following table:
Improved the appearance of button groups when text wraps to multiple lines.
Now, every button in the group will be the same height.
More information:
uswds#5657
Styled aria-disabled to match disabled.
Now disabled styling is applied whether you use disabled (disabled and hidden from screen readers) or aria-disabled (disabled and visible to screen readers).
More information:
uswds#4783
Breaking
Added type="button" to all non-form buttons to prevent default submit behaviors.
This allowed us to remove preventDefault() from the relevant component JavaScript.
More information:
uswds#4695