Components

Button Group

Buttons, fields and printed cells joined into one row (or column) that share their seams: the edge two neighbors have in common is drawn once, by the one before, or by a pencil separator you put between them.

Install

terminal
npx shadcn@latest add @wobko/button-group

First time here? Add the registry to components.json first. How to install

Examples

A row of buttons

Outline buttons side by side share their seams: the edge between two of them is drawn once. Icon buttons, and a column, work the same way.

Cells, fields and separators

A printed cell, an input and a button in one row; two highlighter buttons split by a pencil line; a split button. Filled buttons want a separator, since two markers touching would just be one big blot.

A sourdough order

The group doing a job: a quantity stepper whose number is a printed cell, a size chooser that is a row of buttons, and a primary action to finish. The status line says what the stepper did.

A mail toolbar (groups in a group)

The shadcn demo: a ButtonGroup of ButtonGroups. A back button, two text buttons, and a Snooze button joined to a menu trigger whose slip has groups, a destructive row and a sub-menu with a radio choice. Groups put a gap between them; each keeps its own seams.

Nested: pages and arrows

Two groups inside one: five numbered buttons and a previous/next pair. The page you are on is a highlighter button (`aria-current="page"`), the arrows stop at the ends, and the status line says where you are.

Sizes

A group takes the size of its buttons: give every child the same `size` and the same height, and use the matching square size (`icon-sm`, `icon`, `icon-lg`) for the icon button at the end. Extra small is ours.

A button with a menu (Follow)

A split button the way social apps use it: the main action toggles (Follow / Following, with `aria-pressed`) and the chevron opens every other thing you can do with the conversation. The menu's last row is the destructive one.

A select, a field and a send button

A Select trigger, an Input and a Button share seams like any other children, in two groups side by side. The trigger shows only the symbol; the list beneath explains each one. Try changing the currency and sending.

A button that opens a popover

The chevron half of a split button can open anything, not only a menu: here a slip with a text area and a few lines of explanation. The popover is named with aria-label (Radix gives it role=dialog), and focus goes back to the chevron when it closes.

A message composer (with an input group)

A plain add button, then an InputGroup with a toggle inside it: the group's own box holds the field and the voice button. Turning voice mode on disables the field and changes its prompt; the toggle is `aria-pressed` and lights up as a highlighter.

API reference

ButtonGroup

A role=group flex row. It does not draw anything itself: every child (Button, Input, a Select trigger, ButtonGroupText) is its own hand-drawn host, and the group trims the drawing where they meet: a child that is not first loses its start edge, and one that sits before a ButtonGroupSeparator loses its end edge, so a seam is one stroke, not two. A focused child is never trimmed, so its ring stays whole.

PropTypeDefaultDescription
orientation"horizontal" | "vertical""horizontal"Vertical stacks the children and trims their top edges instead. Right-to-left layouts trim the other side.
aria-labelstring-Name the group when the buttons do not explain themselves ("Range", "Text style").

ButtonGroupText

A printed cell in the row ("https://", "@", "kg"): a paper-shade body under an ink box, real text in the hand font. Not a control: it has no hover or focus.

PropTypeDefaultDescription
asChildbooleanfalseRender your own element, e.g. a <label htmlFor>, with the cell's drawing inside it.
seedstring | number-Pins the hand of this cell.

ButtonGroupSeparator

A Separator (pencil, vertical by default) that stretches to the group's height and takes the place of the two edges around it. Takes every Separator prop: variant, orientation, decorative.

PropTypeDefaultDescription
orientation"horizontal" | "vertical""vertical"Use horizontal in a vertical group.

buttonGroupVariants

The cva function behind ButtonGroup, for laying out another container the same way.

PropTypeDefaultDescription
orientation"horizontal" | "vertical""horizontal"Same as ButtonGroup.

Accessibility

  • The group is role=group: give it an aria-label when the buttons alone do not say what they belong to. It adds no keyboard behavior of its own; Tab visits each control in order (use ToggleGroup for one tab stop with arrow keys).
  • A separator between buttons is decorative (role=none); the buttons keep their own names and states.
  • A focused child is lifted above its neighbors and keeps its whole blue felt ring; in Windows high contrast the drawing is replaced by each control's real border.
  • ButtonGroupText is plain text: give an input it labels a real label (use asChild with <label htmlFor>) or an aria-label.

Source

The files the CLI copies into your project.

Loading the source