Toggle Group
A set of two-state buttons that can be toggled individually or exclusively. Single or multiple selection with full keyboard support.
Installation#
pnpm dlx shadcn@latest add @davinciui/toggle-groupUsage#
The group owns selection and keyboard navigation; items inherit its variant and size unless overridden. Use type="multiple" with array values when more than one item may stay pressed.
ToggleGroup └── ToggleGroupItem
Composition#
Use the following composition to build a Toggle Group:
ToggleGroup
└── ToggleGroupItemAPI Reference#
| Prop | Type | Default |
|---|---|---|
typeSelection mode. Multiple uses array values. | "single" | "multiple" | "single" |
valueControlled pressed value(s). Empty string means nothing pressed in single mode. | string | string[] | — |
defaultValueUncontrolled initial pressed value(s). | string | string[] | — |
onValueChangeFires when the pressed value(s) change. | (value: string | string[]) => void | — |
variantVisual treatment, inherited by items. | "default" | "outline" | "default" |
sizeItem size, inherited by items. | "default" | "sm" | "lg" | "default" |
spacingGap between items. Spaced items get full rounding. | "none" | "sm" | "lg" | "none" |
orientationLayout direction and arrow-key axis. | "horizontal" | "vertical" | "horizontal" |
disabledDisable the whole group or a single item. | boolean | false |
value (item)Unique value identifying the item within the group. | string | — |
Accessibility#
Base UI manages a group with roving tabindex: arrow keys move focus along the orientation axis and loop, while each item exposes aria-pressed. Tab enters and leaves the group; disabled items are skipped.
Motion#
No meaningful motion; transition-all only smooths color and border changes. There is no timing or easing prop and no prefers-reduced-motion detection.
Changelog#
- Single and multiple selection with roving arrow-key navigation.
- Default and outline variants with sm, default, and lg sizes.
- Segmented and spaced layouts plus vertical orientation.
- Logical rounding and direction-aware keyboard handling for RTL.
RTL Support#
Wrap the group in dir="rtl". Segments use logical rounding so the first and last items mirror automatically, shared borders follow the inline direction, and arrow-key navigation follows the reading direction. Nothing else changes — selection, spacing, and disabled logic are direction-agnostic.
View source
Keep in mind
Need a custom component?
I build bespoke UI components & websites tailored to your brand.

