This task defines the minimum viable product (MVP) of the ButtonGroup component.
Scope
The MVP covers the Abstract Wikipedia use case.
Design spec
Anatomy
A ButtonGroup consists of 2 or more Button components displayed horizontally adjacent to each other. Each Button represents a related action.type="primary", action="progressive", and action="destructive" are not allowed in ButtonGroups, and type="quiet" is not part of the MVP scope, so only default, normal buttons are allowed here.
The design specifies that icons should be used consistently across buttons: buttons in an ButtonGroup should all be one of the following:
- Text only
- Icon + text
- Icon-only
If feasible, we should inspect the data or slot contents to see if this specification is met and, if not, emit a warning to the console explaining that icon usage should be consistent across buttons.
Style
The initial component will present the following visual features:
- Buttons are displayed next to each other (horizontally)
- The borders of adjacent buttons overlap
- The first and last buttons have rounded corners on the outside; all the other corners are sharp (not rounded)
- Disabled behavior:
- The ButtonGroup as a whole can be disabled, in which case all of its child buttons are disabled
- Any button within a ButtonGroup can be individually disabled
Interaction
Each button is clickable, but no more interaction needs to be implemented in the ButtonGroup component.
Documentation
- Structure: ButtonGroup is part of the "Button" sidebar group
- Content:
- A demo with three regular buttons. This demo should explain that quiet buttons are not yet supported, and primary/progressive/destructive buttons are not allowed
- A demo with three icon-only buttons. This demo should explain that icons should be used consistently in button groups, e.g. no buttons have icons, all buttons have icons and text, or all buttons are icon-only. It should also explain that buttons should only be icon-only if self-explanatory icons are used. See the design spec for a good example.
- A maximum example with 5 buttons. At least one of the buttons should have a very long label and the button group should break to two rows.
- A configurable demo is not recommended for this component.
Considerations
Not in scope:
- Groups of quiet buttons are not in scope for the MVP
- Enforcing a maximum number of buttons by moving excess buttons into a menu below a "More" button is not in scope for the MVP
Open questions: see T311537. The outcome of these proofs of concept will determine the API for both ButtonGroup and ToggleButtonGroup.
Acceptance criteria
This task will pass from the designer to the developer once the Figma spec is created.
- A Figma spec sheet is created for the component that includes the scope defined here. A link to the Figma spec sheet's MVP version has been added to this task's description.
- The initial component is implemented in Codex.
Design Review
-
Add configurable demo in the pageIt won't be part of the MVP - Add the maximum examples described here
- Fix stacked buttons
- Delete Go back or Go next from the buttons in the button group examples
Test Cases
Existing test cases for reference
- Test maximum cases:
- Entering a long text as a button label - would this truncate or uniformly expand all buttons in the group?
- When there is not enough horizontal space for all buttons the rest of buttons must be stacked
- Consistent button state across major browsers - there has been some history of visual differences seen in Safari 15.1.