Actions

ButtonGroup

Groups related buttons into one control.

Server-renderable1 export

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

ButtonGroup props. All native attributes of the underlying element are also accepted and forwarded.
PropTypeDefaultDescription
orientation"horizontal" | "vertical""horizontal"Layout axis.
attachedbooleantrueJoin the buttons into a single visual control.
aria-labelstringAccessible 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.