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.

content
size
selectionMode
import { ButtonGroup } from "@/components/base/button-group/button-group"; <ButtonGroup size="lg" />

The items in this demo are fixed

The content picker swaps between 4 fixed trios. A group needs 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.

The components in this family, with their descriptions and import paths
ComponentDescriptionImport from
ButtonGroupThe segmented container; manages selection mode and size for its items.@/​components/​base/​button-group/​button-group
ButtonGroupItemOne 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.

Variants by size
smmdlg

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.

text
icon leading
icon only
dot

An icon-only item needs an aria-label

Every icon-only item above carries one. The kit adds no accessible name to an item without children; details are on the Code tab under Accessibility.

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.

single (default)
multiple
single, disallowEmptySelection

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.

rest
hover
focus-visible
selected
disabled item
disabled group

Selected and hover share one treatment

The style object gives 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.