elementsbutton-group
ButtonGroup
Cohesive group of related buttons with shared size, variant, and orientation.
Import#
Usage#
ButtonGroup joins the edges of direct button children and provides shared size and variant
defaults. A child Button can override either default when needed.
Add an accessible label when the surrounding content does not already name the group.
Set separator to render a decorative separator between adjacent controls. Customize its root
with the separator slot in classes or styles.
Slot Structure#
Examples#
Basic#
Variants#
Sizes#
Orientations#
Horizontal and vertical groups using compact quantity controls.
Separators#
Toggle separators between adjacent controls with a switch.
Popover#
Compose a primary button with a Popover trigger inside the same group.
Dropdown#
A report export action composed from a button trigger and a dropdown menu.
API Reference#
Attributes#
Slot
root4 attributesContainer that joins the edges of its direct button children.
Data Attributes
| Data Attribute | Description |
|---|---|
| data-orientation | Stores the rendered orientation. |
| data-size | Stores the resolved size variant. |
| data-variant | Stores the resolved visual variant. |
ARIA Attributes
| ARIA Attribute | Description |
|---|---|
| role | Defines the semantic role exposed to assistive technology. |
Props#
| Prop | Type | Default | Description |
|---|---|---|---|
| children | JSX.Element | — | Buttons or compatible controls rendered as a cohesive group. |
| class | ClassValue | — | Class applied to the component root or trigger element. |
| classes | ButtonGroupT.Classes | undefined | — | — |
| id | string | undefined | — | Optional identifier for the group root. |
| orientation | "horizontal" | "vertical" | undefined | — | — |
| ref | JSX.HTMLElementTags["div"] extends { ref?: infer Ref; } ? Ref : never | undefined | — | — |
| role | JSX.AriaAttributes["role"] | undefined | — | ARIA role for the group root. |
| separator | boolean | undefined | — | Whether to render a decorative separator between adjacent controls. |
| size | "xs" | "sm" | "md" | "lg" | "xl" | "icon-xs" | "icon-sm" | "icon-md" | "icon-lg" | "icon-xl" | undefined | — | — |
| style | JSX.CSSProperties | undefined | — | — |
| styles | ButtonGroupT.Styles | undefined | — | — |
| variant | "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | undefined | — | — |