Group
Visually joined buttons that act as a single control. A group collapses the gap between adjacent buttons so they read as one segmented control - useful for view switchers, toolbars, and exclusive or multi-select toggle sets. The group is purely visual; each child remains a fully accessible button.
Render a <div role="group"> wrapper around pre-rendered child HTML.
The group component is CSS only, consumers write their own markup. This inline helper is a stand-in used exclusively by the stories so controls (classes, attributes) flow through to a deterministic DOM shape for interaction tests.
Usage
When to use
- To present a set of related actions as a segmented control (e.g. view switcher, zoom level, alignment)
- To offer a toggle set where one option can be active at a time
- To group closely related utility actions in a toolbar
When not to use
- To group unrelated actions - use standalone buttons with spacing
- To group form inputs - use fieldset
- To attach a button to an input - use addon
Do
- Keep labels in a group short and consistent in length
- Use
aria-pressedon toggle buttons to communicate active state - Label the group itself via
aria-labelor a visible heading
Don't
- Don't mix unrelated actions in a single group
- Don't rely on active-state color alone - pair it with
aria-pressed - Don't group more buttons than comfortably fit on the smallest supported viewport
API
Slots
| Slot | Required | Description |
|---|---|---|
content | - | Controls rendered inside the group - typically buttons, optionally mixed with other inline elements. |
Props
| Prop | Type | Default | Description |
|---|---|---|---|
classes | array | - | Additional CSS class words merged into the root element. |
attributes | object | - | Additional HTML attributes spread on the root element. Pass aria-label here to name the group. |
Classes
| Class | Capability | Default | Description |
|---|---|---|---|
.sm | Size | - | Small. |
.md | Size | Yes | Medium. |
.lg | Size | - | Large. |
.vertical | Orientation | - | Children flow along the vertical axis. |
Examples
Horizontal
Buttons joined horizontally as a single segmented control.
Vertical
Buttons joined vertically for compact toolbars or sidebars.
Toggle
Toggle buttons with aria-pressed communicating active state.
Sizes
Small and large size variants.
Accessibility
- WCAG 2.2 AA
- The group container carries
role="group"with anaria-label - Toggle buttons use
aria-pressed="true"/"false"for active state - Every child button remains keyboard reachable
- Visible focus indicator on each child button