Button group
Connected actions joined into one surface: hairline dividers, a gliding hover highlight, and responsive auto-collapsing labels.
Used forEditor toolbarsSegmented view switchesResponsive header controls
Install with the shadcn CLI
Where it’s used
Editor toolbars
Text alignment, formatting, and view toggle controls.
Segmented view switches
Switching between Grid, List, and Table layouts.
Responsive header controls
Actions that collapse gracefully on mobile devices.
What it handles for you
Multiple buttons side by side usually create cramped margins and multiple clashing borders. This component joins actions into one continuous hairline surface with smooth kinetic focus gliding.
Gliding highlight
A soft pill highlight glides seamlessly between segments on hover or arrow-key focus.
Quiet dividers
Internal hairline dividers fade out beside the active segment so the highlight reads as a clean shape.
Auto-collapsing labels
When container space is constrained, text labels collapse into icons automatically while preserving full accessibility and titles.
Horizontal & vertical
Supports both horizontal toolbars and vertical sidebar action bars.
Overview
Related actions fused into a single hairline capsule with internal dividing hairlines. A soft highlight glides between segments under cursor hover or keyboard navigation, dividers quietly step aside next to active items, and labels automatically collapse to icons on narrow screens.
States
- idle
- Resting capsule with hairline dividers between segments.
- hovered
- Gliding highlight pill positioned under active segment; neighboring dividers fade.
- focused
- Keyboard focus ring and highlight navigating with arrow keys.
- compact
- Collapsed labels showing icons on narrow containers.
Usage
Works with
Props
| Prop | Type | Description |
|---|---|---|
| items | ButtonGroupItem[] | Array of action items in the group. |
| variant | "outline" | "solid"default "outline" | Outline with hairline border or solid dark fill. |
| size | "sm" | "md"default "md" | Control height and typography. |
| orientation | "horizontal" | "vertical"default "horizontal" | Layout direction. |
| collapseLabels | booleandefault true | Automatically collapse labels to icons when space overflows. |
Accessibility and motion
- No external animation libraries: uses CSS transitions and native layout geometry.
- Full keyboard accessibility: navigate with Arrow keys, Home, and End.
Requirements
React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.
The CLI also installs ui-interaction-motion.
Source
Registry item: /r/button-group.json