Toggle Group
Related toggle buttons with shared single-select or multi-select state.
Purpose
Use Toggle Group for related toggle buttons that share single-select or multi-select state, such as formatting, alignment or view controls.
Segmented controls
Installation
With the Siteplane registry alias configured, add the component and import the installed source from your app.
CLI
pnpm dlx shadcn@4.16.1 add @siteplane/toggle-groupImport
import {
ToggleGroup,
ToggleGroupItem,
ToggleGroupSeparator,
} from "@/components/ui/toggle-group";Need the machine-readable source metadata? View registry JSON.
Usage
Toggle Group is a segmented control. Single-select gets the sliding indicator; multi-select keeps per-item state.
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
export function Example() {
return (
<ToggleGroup defaultValue={["week"]}>
<ToggleGroupItem value="day">Day</ToggleGroupItem>
<ToggleGroupItem value="week">Week</ToggleGroupItem>
</ToggleGroup>
);
}Examples
Selection modes, sizes, orientation, separators, widths and form integration are props and compositions of the same primitive.
Multiple selection
With multiple, several items can be pressed at once and each keeps its own background.
Sizes
Vertical
With separators
Icon + text
Disabled
Full width
With width="full" the group stretches to its container; grow items share the extra space.
View switcher
Controlled selection that ignores empty updates so one view always stays active.
Form integration
Wrapping
wrap lets a long group break into several rows instead of overflowing.
Item padding and width
padding="comfortable" widens the item, maxWidth="label" truncates long labels.
API Reference
The reference lists the source-owned exports and props that are easy to miss in visual examples. Inherited Base UI props remain available unless the wrapper narrows them.
ToggleGroupaccepts single or multiple selection, controlled or uncontrolled value arrays, orientation, disabled state, Button-style size and Toggle variant.- Each
ToggleGroupItemrequires a uniquevalueand inherits group size and variant unless explicitly overridden. ToggleGroupSeparatordefaults toorientation="vertical"; setorientation="horizontal"inside a vertical group.- Use
multiplefor several active items; omit it for one active value.
Motion
Component motion uses the shared Siteplane motion contract. See the global motion guide for provider setup, tokens and reduced-motion behavior.
- Pressed background, border and focus feedback use the native Toggle motion contract without changing group measurements.
- Reduced motion keeps selection immediate and removes non-essential feedback transition.
Accessibility
- Give the group an accessible name and every icon-only item its own
aria-label. - Keep single- and multi-select semantics aligned with the actual state model.
- Pair invalid state with visible error text when the group participates in a form.
Implementation Guidance
- Use Radio Group when explicit form-choice semantics are more important than compact toolbar presentation.
- Match separator orientation to the group direction.
- Do not build independent Toggle buttons when their values are meant to share one group state.