Button Group
Web/MobileA container that groups related buttons together with consistent styling.
Installation
pnpm dlx cubix-ui@latest add button-groupUsage
import { Button } from "@/components/cubix/button"
import { ButtonGroup } from "@/components/cubix/button-group"
<ButtonGroup aria-label="ویرایش">
<Button variant="outline" size="sm">
کپی
</Button>
<Button variant="outline" size="sm">
برش
</Button>
<Button variant="outline" size="sm">
چسباندن
</Button>
</ButtonGroup>
Composition
Use the following composition to build a ButtonGroup. Joined corners and borders use logical start and end, so the same markup is correct in RTL and LTR.
ButtonGroup
├── Button, TextFieldInput or Select
├── ButtonGroupSeparator
├── ButtonGroupText
└── ButtonGroup (nested)Accessibility
- 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 stack the controls vertically.
Size
Control size with the size prop on each button. Keep every control in a group at the same size - sm is 32px, default is 40px, and lg is 48px.
Nested
Nest ButtonGroup components to create spaced clusters of related actions.
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
Join a Cubix TextFieldInput with a button. Default field height is 40px, so it lines up with the default button size.
Text
Use ButtonGroupText for a prefix or label next to TextFieldInput. Pass render={<label />} to label the field. URLs read left to right, so this group sets dir="ltr".
Select
Pair a Select with a TextFieldInput and a button. All three default to 40px, so the joined edges line up.
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 | - | Render the text slot as another element, such as a label. Same API on Base UI, React Aria, and Radix. |
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). |
| children | React.ReactNode | - | Label or helper text shown inside the group. |