Skip to content

Button group

Buttons joined into one control, with separators and text slots.

For actions that belong together, such as the buttons of one toolbar. For a choice between options use @khaeli/toggle-group or @khaeli/segmented-toggle-group. A group inside a group sits 8px from its neighbours.

Joined buttons

Vertical

With a separator

With text

Page 2 of 8

With an input

Nested groups

Installation

npx shadcn@latest add @khaeli/button-group

Install @khaeli/foundation first: this item's styling lives in its tokens and [data-slot] rules.

Installs with

npm packages
  • @base-ui/react ^1.7.0
  • class-variance-authority ^0.7.1

Keyboard

Tab
Moves to the next button. Every button is its own tab stop: the group adds no arrow-key movement.
EnterSpace
Activates the focused button.

Accessible name

  • The group is a role="group" with no name of its own. Give it an aria-label that says what its buttons share, such as Task actions.
  • An icon-only button in the group needs its own aria-label.
  • ButtonGroupText is plain text. Rendered as a <label> with render and htmlFor, it names the input beside it.
  • ButtonGroupSeparator is a role="separator" and needs no name.

Registry JSON

The item as the shadcn CLI reads it, with every file it ships: https://ui.khaeli.com/r/button-group.json