ButtonGroup
Groups related buttons into one control.
Joins buttons visually by collapsing the radii and borders between them, while leaving each one an independently focusable button.
Import
import { ButtonGroup } from "@abbainitiative/ui";Also available from the subpath entry @abbainitiative/ui/button-group.
This component has no state and no event handlers, so it renders inside a Server Component without a client boundary of your own.
Examples
Attached and spaced
<Stack gap={4}>
<ButtonGroup aria-label="Text alignment">
<Button variant="outline">Left</Button>
<Button variant="outline">Centre</Button>
<Button variant="outline">Right</Button>
</ButtonGroup>
<ButtonGroup aria-label="Actions" attached={false}>
<Button>Save</Button>
<Button variant="ghost">Cancel</Button>
</ButtonGroup>
</ButtonGroup>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| orientation | "horizontal" | "vertical" | "horizontal" | Layout axis. |
| attached | boolean | true | Join the buttons into a single visual control. |
| aria-label | string | Accessible name for the group. Strongly recommended. |
Accessibility
- Renders `role="group"`; supply `aria-label` or the announcement is meaningless.
- Every button stays individually reachable with Tab.
- The focused button's ring is raised above its neighbours so it is never clipped.