Installation
Theme
Mode

Forms & input

Button group

A row of attached buttons that act as one control — a segmented view switch, a formatting toolbar, a cluster of related actions. Tighter than separate buttons, lighter than tabs.

$npx shadcn@latest add @orbit/button-group

Overview

Live · click to select

Modes

Single-select for one-of choices, multi-select for independent toggles, or plain actions that each just fire.

Single-select — one choice active at a time, like a radio.
view: board
Multi-select — independent toggles, like checkboxes.
formats: [bold]
Actions — each button fires; nothing stays pressed.
nothing fired yet

Icon groups

Compact icon groups are the classic toolbar — alignment, text formatting, or a zoom stepper with a value in the middle. Icon-only segments are square; always give them a title or aria-label.

Sizes

sm 30px · md 34px (default) · lg 40px, with 8px end radii and a 1px shared border. Small for dense toolbars, medium by default, large for primary view switches.

Disabled

Disable the whole group or single segments. Disabled segments drop to a flat neutral treatment and are skipped by keyboard focus.

Controlled & uncontrolled

Pass defaultValue to let the group manage its own selection, or value + onValueChange to own it. Single mode works with a string, multi mode with a string array.

value: week

Props

PropTypeDefaultDescription
mode"single" | "multi" | "actions""single"Radio-style selection, independent toggles, or plain buttons that just fire.
size"sm" | "md" | "lg""md"Segment height: 30 / 34 / 40px.
valuestring | null · string[]Controlled selection — a string in single mode, an array in multi mode.
defaultValuestring · string[]Initial selection (uncontrolled).
onValueChange(value) => voidFires with the new selection: the picked string (single) or all pressed values (multi).
disabledbooleanfalseDisables every segment in the group.
…restHTMLAttributes<HTMLDivElement>Forwarded to the group root, including ref and aria-label.
PropTypeDefaultDescription
valuestringItem — segment identity within the group value. Required in single/multi modes.
iconReactNodeItem — 15px leading glyph. With no children the segment becomes a square icon button.
disabledbooleanfalseItem — disables just this segment.
titlestringItem — tooltip; doubles as the aria-label for icon-only segments.
…restButtonHTMLAttributesItem — forwarded to the underlying <button>, including ref and onClick.

Usage

Do

Group genuinely related choices

Views of one dataset, formatting toggles for one selection — things that share context.

Don’t

Mix unrelated actions

Save next to Delete next to Share isn’t a group; those are separate buttons with their own weight.

Do

Keep it to ~2–5 segments

Past five, a segmented control gets cramped — switch to a Select or Tabs.

Don’t

Use it for primary navigation

Changing the whole page is Tabs’ job; a button group stays within one view.

Keyboard & accessibility

Single and multi groups render role=group with aria-pressed toggle buttons: Tab enters the group, Left/Right arrows (and Home/End) move focus within it, Enter or Space toggles. Actions mode renders plain buttons that Tab moves between. Icon-only segments take their accessible name from title or aria-label; give the group itself an aria-label.

Tab in, then use arrow keys