ToggleButtonGroup
A segmented control / toggle group (single or multiple selection).
Signature
Density
Viewport
Theme and light/dark are set in the top barWhen to use
A segmented control / toggle group (single or multiple selection).
Accessibility
Always render a visible <label> (the label prop wires htmlFor/id for you). Errors set aria-invalid and are announced via aria-describedby. Required fields expose aria-required.
Install and import
npx shadcn@latest add @prism/toggle-button-group
import { ToggleButtonGroup } from '@/components/prism/ToggleButtonGroup';
In a no-build prototype, read it from the bundle instead: const { ToggleButtonGroup } = window.PrismDesignSystem_39d121;
Props
| Prop | Type | Required | Description |
|---|---|---|---|
items | ToggleItem[] | Yes | |
value | string | string[] | — | Controlled value: a string (single) or string[] (multiple). |
defaultValue | string | string[] | — | |
selectionMode | "single" | "multiple" | — | |
onChange | (value: string | string[]) => void | — | |
isDisabled | boolean | — | |
wrap | boolean | — | Let options flow onto more lines instead of scrolling sideways when they don't fit. |
selectedVariant | "default" | "accent" | — | "accent" fills the selected segment with the accent — for menus and toolbars where the default raised segment is too subtle. |
id | string | — | Accepted so Field's render props can be spread; a group can't carry them, so they're ignored. |
className | string | — |