Button Group
Related buttons joined into one control: neighbors share a border and only the outer corners are round. For a row of actions, a main action with its options, or a field with the action that uses it.
Ritla scan of this preview: 41 of 41 checks3 breakpointsScanned
Preview
Mirrored is the same English content laid out right to left: it separates a mirroring bug from a translation one.
Installation
Add the component
npx ritla add button-groupAlso works with shadcn:
npx shadcn@latest add @ritla/button-groupOr copy by hand
Installing by hand copies the component's source into your project. The source comes with a Ritla UI license, so the CLI is the short way to the same files.
Usage
import { ButtonGroup } from "@/components/ui/button-group";import { Button } from "@/components/ui/button";<ButtonGroup aria-label="Message actions"> <Button variant="outline" size="md">Archive</Button> <Button variant="outline" size="md">Report</Button> <Button variant="outline" size="md">Snooze</Button></ButtonGroup>Examples
Split
An action with a menu of its options is a Split Button: use SplitButton, the action and a menu half with its own name, one control as in Figma.
With input
A field and the action that uses it, joined so the button reads as part of the field. The label stays visible above it, and className="items-end" aligns the group on the field's box. Don't set dir="ltr" on the Input here: its box would turn LTR and the joined corner would move; the input's dir="auto" already keeps a Latin code left to right.
Vertical
orientation="vertical" joins top to bottom, like a map's zoom controls.
API reference
ButtonGroup
| Prop | Type | Default | Description |
|---|---|---|---|
aria-label | string | None | Required: what the actions are about ("Message actions"), read when focus enters the group. |
orientation | "horizontal" | "vertical" | "horizontal" | A row or a column. |
children | ReactNode | None | Ritla UI Buttons, IconButtons and an Input, all one size. Figma's Type is what you put here, not a prop. The row doesn't wrap; on a phone keep it within the screen width: use sm buttons, or move actions into More actions. |
ButtonGroupSeparator
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | None | The line between two filled buttons; pass another background for another fill. |
Accessibility
Keyboard
Keys are written for left-to-right. In right-to-left the arrow keys swap: the one pointing toward the reading direction moves forward.
| Key | Action |
|---|---|
| Tab | Moves through each button in order, from the inline start. |
ARIA
role="group"named byaria-label; each button keeps its own role and name.- An icon-only button needs a name (
label), and the split caret's name differs from the action's. - To pick one option from a set, use a Toggle Group: actions here never stay pressed.
Arabic and RTL notes
Mirrors
- The first button sits at the inline start (the right) with the rounded corners, the last one on the left.
Does not mirror
- The caret and the three dots don't mirror, and Latin values in the field (a promo code) stay left to right.
- Numerals
- The group has no numbers of its own; any number in the labels follows
numerals. - Arabic typography
- Each button keeps its own type and size; the row takes its height from them, so use one size.
Checks it passes
The Ritla checks this component satisfies by construction. Used as documented, it does not bring these defects onto your page.
- Arabic text falling back past the declared font family (measured, declared, or a webfont that failed to load)
- letter-spacing applied to Arabic text (breaks the connected script)
- Clipped text: content wider than its box with overflow hidden and no ellipsis
- Fixed-pixel-width container whose Arabic text exceeds the space