ButtonGroup
Join related buttons into one visual control set.
Anatomy#
The caller supplies the child buttons and places ButtonGroup.Separator between them where needed;
the group renders no separators of its own.
Usage#
Use ButtonGroup when adjacent actions should read as one control set. Each child remains its own interactive control; the group supplies layout and shared presentation.
Use ToggleButton inside the group for independently pressed actions. ButtonGroup does not coordinate selection or add toolbar keyboard navigation.
Composition#
Root size (xs to xl), variant, and tone set defaults for every descendant Button,
ToggleButton, and CopyButton, and each child can override them. When the group omits one, each
child keeps its own default (solid for Button, ghost for ToggleButton and CopyButton).
orientation (horizontal by default, or vertical) sets the layout direction. Compose a menu or
popover trigger as a child when an action needs an overlay.
The root renders a div with role="group", so give it an aria-label. Set role="toolbar" only
if you also provide the toolbar keyboard behavior.
Separator#
Insert ButtonGroup.Separator only where an explicit boundary is useful. Its orientation is
perpendicular to the group axis: vertical in a horizontal group and horizontal in a vertical group.
It renders a div with role="separator".
Examples#
Basic#
Set variant once on the group so every action in the bar shares it.
Toggle buttons#
Compose ToggleButton children for independently pressed actions. They inherit the group’s size,
tone, and variant (the unpressed appearance); activeVariant controls each button’s pressed
appearance.
Separator#
Insert ButtonGroup.Separator to visually divide buttons within a group.
With dropdown#
Pair a primary Button with a DropdownMenu.Trigger for split-button actions.
With popover#
Attach a Popover.Trigger to open a compact panel alongside a primary button.
Vertical#
Set orientation="vertical" to stack buttons in a vertical group.
API Reference#
Attributes#
data-orientationProps#
ButtonGroup#
Props for the ButtonGroup component. Renders a <div> element by default.
Separator#
Props for the ButtonGroup.Separator component. Renders a <div> element by default.