Reference index

Components

Button Group

Joins related buttons into one segmented control divided by shared 1px ink rules, with a text cell and separator.

Preview

Install

bash

npx shadcn add @eloquent/button-group

Usage

tsx

import { Button } from "@/components/ui/button";
import { ButtonGroup, ButtonGroupSeparator, ButtonGroupText } from "@/components/ui/button-group";

<ButtonGroup aria-label="Edition navigation">
  <Button variant="outline">Previous</Button>
  <Button variant="outline">Today</Button>
  <Button variant="outline">Next</Button>
</ButtonGroup>

<ButtonGroup aria-label="Edit">
  <Button variant="ghost">Cut</Button>
  <ButtonGroupSeparator />
  <Button variant="ghost">Copy</Button>
</ButtonGroup>

Name the group with aria-label or aria-labelledby. ButtonGroupText takes a render prop (upstream asChild), for example render={<label htmlFor="q" />}.

States

Edition
StateTreatment
JoinedEach member overlaps its neighbour's 1px ink border, so there is one shared rule and no gap
Press, pressed, disabledThose of each member button
Focus2px ink outline, 2px offset; the focused member sits above its neighbours
Text celltint-1 fill with a 1px ink border; not interactive
SeparatorA 1px ink rule that takes its own space, for ghost or link members

Keyboard

KeyAction
Tab / Shift+TabMove between members; each member is its own tab stop (disabled members are skipped)
Enter / SpaceActivate the focused button

Vietnamese

Ink adaptation

Upstream removes radius from inner edges and adds shadows; here there is neither. Members share overlapping 1px ink rules, the text cell is a tint-1 panel, and no hover effect is added. Uses @eloquent/button for its members.