ToggleGroup
A component that manages a group of toggle buttons, supporting both single and multiple selection modes.Import
Components
ToggleGroup
The container component that manages toggle state across items.The size of all items in the group.Options:
xs- 28px height (var(—space-28))s- 32px height (var(—space-32))m- 36px height (var(—space-36))l- 40px height (var(—space-40))
The visual style variant for all items.Options:
ghost- Transparent background, visible on hover (default)tertiary- Glass-like appearance with shadow and blursecondary- Subtle gray background
Hide separators between items.
Controlled array of selected toggle values.
Default array of selected toggle values for uncontrolled usage.
Callback fired when the selection changes.
Whether to allow all items to be unselected. Passed to Base UI.
ToggleGroupItem components to display in the group.
Additional CSS classes to apply to the group container.
Explicit escape hatch for intentional structural overrides.
ToggleGroupItem
Individual toggle button within a ToggleGroup.Unique value to identify this toggle in the group.
Leading icon displayed before the label.
Icon displayed when toggle is pressed (for icon morphing).
Trailing icon displayed after the label.
Enable morph animation between icons. When false, uses fade transition.
Text label for the item.
When true, disables interaction and applies disabled styling.
Additional CSS classes to apply to the item.
Explicit escape hatch for intentional structural overrides.
Usage
Basic Toggle Group
Variants
Sizes
With Icons
Icon-Only Items
Icon Morphing
Without Separators
Controlled Toggle Group
Uncontrolled with Default
Multiple Selection
Animation
ToggleGroup includes sophisticated animations:Icon Animations
Fade Mode (default):- Duration: 150ms
- Easing: [0.19, 1, 0.22, 1] (custom ease-out)
- Y-axis translation: 8px
- Scale: 0.5 to 1.0
- Blur: 0 to 8px
- Spring: bounce 0.2, duration 250ms
Label Animations
Layout animations use spring physics:- Spring: bounce 0.15, duration 250ms
- Automatically adjusts width when text changes
prefers-reduced-motion.
Behavior
- Items automatically track their pressed state based on the group’s value
- Gap of 4px (var(—space-4)) between items
- Separators are 16px tall (var(—space-16)) and use border-interactive-default
- Active state on items scales down to 0.98
- Focus is managed at the item level with proper z-index
Accessibility
- Built on Base UI’s
ToggleGroupandToggleprimitives - Items use
data-pressedattribute to indicate state - Focus ring appears on individual items with z-10 layering
- When using icon-only items, always provide
aria-label - Supports keyboard navigation between items
- Disabled items use
cursor-not-allowedand reduced opacity
Design Tokens
The ToggleGroup components use the following design tokens: Colors:actions-tertiary-default,actions-tertiary-hover,actions-tertiary-disabledactions-secondary-default,actions-secondary-hover,actions-secondary-disabledcontent-strong,content-subtle,content-disabledborder-interactive-default(separators)
- Heights:
space-28,space-32,space-36,space-40 - Horizontal padding:
space-10,space-12,space-16 - Gap between items:
space-4 - Gap between elements:
space-2,space-4 - Icon sizes:
space-16,space-18 - Label padding:
space-4,space-6 - Separator height:
space-16
- Border radius:
radius-max - Font weight:
font-weight-medium - Focus ring:
utility-focus-inner,utility-focus-outer - Shadows (tertiary):
utility-shadow-l1,utility-shadow-l2,utility-shadow-l3