Button group

Free

Icon buttons on one glass tray, each named by a tooltip with its key hint, with arrow keys to move along the row: the toolbar under a composer or an editor.

npx shadcn@latest add @pixilui/button-group

Preview

Tooltips wait once, then glide along the row as you scan it.
Show

When to use

Use it when

  • A composer's tools: attach, mention, dictate, then send.
  • An editor's or a canvas's small set of icon actions that belong together.

Use something else when

  • Choosing one of several options: use the segmented control.
  • Actions with words on them: use Buttons in a row with a gap.
  • More than about six tools: group them, or move the rest into a menu.

Installation

Terminal
npx shadcn@latest add @pixilui/button-group

Adds button-group.tsx with button.tsx and tooltip.tsx, and installs clsx, tailwind-merge and @base-ui/react. First PixilUI item in this app? Add the registry once, as in Installation.

Usage

example.tsx
import { ButtonGroup } from "@/components/pixilui/button-group";

<ButtonGroup aria-label={aria-label} actions={actions} />

Sizes to its buttons; never wider than its container. Small buttons keep a 40px hit area on desktop and 44 on touch.

API reference

PropTypeDefault
aria-labelRequiredstring–What the row acts on, for screen readers ("Editor").
actionsRequiredButtonGroupAction[]–The buttons, in order. Keep the primary last.
sizeButtonSize"sm"Height of every button: xs 24, sm 28 (default), md 32, lg 36, xl 44.
labelsbooleanfalseShow each action's label as its text (an attached group: Preview, Diff, Logs) instead of icon-only.

Keyboard

TabMoves focus into the row and on out of it.
← →Moves between the row's buttons, wrapping at the ends; mirrored in right to left.
EnterPresses the focused button.
EscCloses the open tooltip and leaves focus where it is.

Accessibility

  • role="toolbar" with the aria-label you pass ("Editor").
  • Every button is icon-only and named by its label; keep the tooltip text close to it.
  • Tooltips open on keyboard focus too, so the key hint is reachable without a mouse.
  • A disabled action uses aria-disabled, so it stays in the arrow-key path and keeps focus.

Motion

  • The first tooltip waits 400ms; the next ones open at once while the pointer slides along the row.
  • Each button presses at .96 in 150ms ease-out; press always wins over hover.
  • Reduced motion: no press scale; tooltips fade only.

PixilUI Pro opens Thu 10 Dec. The first 20 licenses are $99.