Button Group

A container that groups related buttons together with consistent styling.

Installation

pnpm dlx cubix@latest add button-group --base radix

Usage

Import
import { Button } from "@/components/cubix/button"
import {
  ButtonGroup,
  ButtonGroupSeparator,
  ButtonGroupText,
} from "@/components/cubix/button-group"
Example
<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
└── ButtonGroupText

Accessibility

  • The group has role="group".
  • Use Tab to move between the controls in the group.
  • Label the group with aria-label or aria-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.

https://

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.

PropTypeDefaultDescription
orientation"horizontal" | "vertical""horizontal"Layout direction of the grouped controls.
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).
childrenReact.ReactNode-Buttons, inputs, separators, text, or nested ButtonGroups.

ButtonGroupSeparator

A visual divider between buttons in the group.

PropTypeDefaultDescription
orientation"horizontal" | "vertical""vertical"Divider direction. Vertical is the usual split between side-by-side buttons.
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).

ButtonGroupText

Text shown inside the group, such as a prefix or label.

PropTypeDefaultDescription
renderReact.ReactElement-Base UI / React Aria: render the text slot as another element, such as a label.
asChildbooleanfalseRadix: merge props onto the child element instead of a wrapping div.
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).
childrenReact.ReactNode-Label or helper text shown inside the group.