Button groups
Button groups join related toggle buttons into one segmented control with shared edges, for switching views, filters, and modes in place.
Button groups
Button groups join related toggle buttons into one segmented control with shared edges, for switching views, filters, and modes in place.
Demo
Change the props and copy the result. The content picker cycles the four content forms at any size; the other controls are real group props.
The items in this demo are fixed
ButtonGroupItem children, which the playground’s copyable snippet cannot carry, so the snippet covers the group element only and the content pick never reaches it. Paste a full example from the Code tab when starting from scratch.The family
Two components from one module: the group owns the selection and the size, and every child item is a toggle button keyed by its id.
| Component | Description | Import from |
|---|---|---|
| ButtonGroup | The segmented container; manages selection mode and size for its items. | @/components/base/button-group/button-group |
| ButtonGroupItem | One toggle button in the group; supports text, icons, or icon-only content. | @/components/base/button-group/button-group |
Sizes
The 3 sizes, read from the kit’s exported style object. Each one shares its vertical padding and text recipe with the same-named Button size, so a group and a button of the same size sit flush in one row.
| sm | md | lg |
|---|---|---|
Hover and focus states are live. Interact with any cell.
Content forms
The 4 content forms the item supports, each at all 3 sizes, mirroring the Figma component’s Icon axis. Text is the default, for short self-explanatory labels. A leading icon earns its place when the glyph disambiguates similar options at a glance. Icon-only is the densest form, for toolbars whose glyphs are universally understood, and every such item needs an aria-label. The dot marks options that carry a live status, like environments, and is decorative: the label or nearby text must carry the status too.
An icon-only item needs an aria-label
Selection
Selection is single by default: one item at a time, announced as a radio group. Passing selectionMode lets items toggle independently, and disallowEmptySelection keeps at least one item selected. All three groups below are live.
States
Every state below is on the middle item of a real group, except the last, which disables the whole group. Hover and focus re-apply the kit’s own state classes with the variant prefix stripped, so what renders is what the kit ships rather than a repainted approximation.
Selected and hover share one treatment
selected: and hover: the same background and text shade, so a selected item looks exactly like a hovered one. The 3 sizes change spacing only; there are no color variants anywhere in the family.