Button Group
A container that groups related buttons together with consistent styling.
Installation
pnpm dlx cubix@latest add button-group --base ariaUsage
import { Button } from "@/components/cubix/button"
import {
ButtonGroup,
ButtonGroupSeparator,
ButtonGroupText,
} from "@/components/cubix/button-group"<ButtonGroup>
<Button variant="outline">Button 1</Button>
<Button variant="outline">Button 2</Button>
</ButtonGroup>Composition
Use the following composition to build a ButtonGroup:
ButtonGroup
├── Button or Input
├── ButtonGroupSeparator
└── ButtonGroupTextAccessibility
- The group has
role="group". - Use Tab to move between the controls in the group.
- Label the group with
aria-labeloraria-labelledby. - Icon-only buttons inside the group need their own
aria-label.
Examples
Orientation
Set the orientation prop to change the layout.
Size
Control size with the size prop on each button.
Nested
Nest ButtonGroup components to create groups with spacing.
Separator
Outline buttons already have a border. For other variants, add ButtonGroupSeparator to split the group.
Split
Pair a main action with a DropdownMenu trigger for a split button.
Input
Wrap an input with buttons in the same group.
Text
Use ButtonGroupText for a prefix or label inside the group.
Select
Pair the group with a Select and an input.
RTL
Joined corners and borders use logical start/end, so the group stays correct under dir="rtl". To enable RTL support, see the Direction guide.
API Reference
Note: Use ButtonGroup for related actions. Use a toggle group when the controls represent a selected state.
ButtonGroup
The container that groups related buttons with consistent styling.
| Prop | Type | Default | Description |
|---|---|---|---|
| orientation | "horizontal" | "vertical" | "horizontal" | Layout direction of the grouped controls. |
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). |
| children | React.ReactNode | - | Buttons, inputs, separators, text, or nested ButtonGroups. |
ButtonGroupSeparator
A visual divider between buttons in the group.
| Prop | Type | Default | Description |
|---|---|---|---|
| orientation | "horizontal" | "vertical" | "vertical" | Divider direction. Vertical is the usual split between side-by-side buttons. |
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). |
ButtonGroupText
Text shown inside the group, such as a prefix or label.
| Prop | Type | Default | Description |
|---|---|---|---|
| render | React.ReactElement | - | Base UI / React Aria: render the text slot as another element, such as a label. |
| asChild | boolean | false | Radix: merge props onto the child element instead of a wrapping div. |
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). |
| children | React.ReactNode | - | Label or helper text shown inside the group. |