Button Group
A set of related buttons, visually grouped together as a single control.
- Status
- Not tracked
- Code
- In React
- Role
- Action
Usage
This demo is live, and the code below it is the same code, imports included. The component lives in src/ui of this repository and is not published to npm yet.
Showing the grid view.
Pastes as editable layers. Shadows are not exported.
import { useState } from "react";
import { ListBullets, SquaresFour } from "@phosphor-icons/react";
import { ButtonGroup, type ButtonGroupOption } from "@/ui";
const VIEW_OPTIONS: ButtonGroupOption[] = [
{ value: "grid", label: "Grid", icon: <SquaresFour size={18} /> },
{ value: "list", label: "List", icon: <ListBullets size={18} /> },
];
export default function ButtonGroupDemo() {
const [view, setView] = useState<string>("grid");
return (
<>
<ButtonGroup label="View" value={view} onChange={setView} options={VIEW_OPTIONS} />
<p aria-live="polite">Showing the {view} view.</p>
</>
);
}Variants and states
Every specimen is the real component from src/ui, held in one state.
Pastes as editable layers. Shadows are not exported.
Props
- label
- string · default none
- Required. Names the group for screen readers, such as "View".
- options
- { value, label, icon?, iconOnly?, disabled? }[] · default none
- Required. Two to four segments. With iconOnly, the label becomes the button's aria-label.
- value
- string · default none
- The chosen value, when you control it.
- defaultValue
- string · default first enabled option
- The starting value when uncontrolled. One segment is always chosen.
- onChange
- (value: string) => void · default none
- Called with the value of the pressed segment.
- size
- "md" | "lg" · default "md"
- 44px or 48px tall. Icon-only segments are square.
- fullWidth
- boolean · default false
- Stretch to the container with equal segments.
- className
- string · default ""
- Extra classes on the group.
Figma to code
Figma properties by their exact names from Naming, and the React prop that carries each one. The table covers the shared properties that bear on this component; the Figma file decides which of them its component exposes. None means there is no prop for it yet.
- 📐 Size
- size
- md and lg.
- 🎯 State
- value, options[].disabled
- Selected is the chosen value. Hover and focus come from the browser.
- 🖍 Label
- options[].label
- Per segment.
- ☘️ Icon
- options[].icon, options[].iconOnly
- Per segment. Icon-only keeps the label as the accessible name.
Accessibility
What the code in src/ui does today, and what it leaves to you.
Keyboard
- Tab moves through each segment. Enter and Space choose it. Disabled segments are skipped.
Screen readers
- A group named by label. Each segment is a toggle button with aria-pressed, so the chosen one is read as pressed.
- Icons are aria-hidden. An icon-only segment is named by its label.
What you still need to do
- Show the result of the choice, such as switching the view, right away. A segment is a choice, not a submit.
- Use Tabs instead when each choice shows a different panel of content.
- This component draws no focus indicator of its own. On this site a global :focus-visible rule draws a 2px outline in the border/focus role (--color-role-border-focus). Copy the role tokens and that rule, or an equivalent, into your app.
When to use
Segmented choices such as view toggles (grid/list) or grouped filters.
Do and don't
Do
- Keep labels short so groups stay compact.
- Use for mutually exclusive choices.
Don't
- Mix unrelated actions in a single group.
- Put more than four options in one group. Two to four options stay easy to scan.
Related
Other untracked components.
- Icon ButtonA compact button that uses only an icon to represent its action.Not tracked
- Code BlockShows read-only code with a copy button, in plain text that keeps 7:1 contrast in light and dark.Not tracked
- LinkNavigates the user to another page, section, or resource.Not tracked
- SelectLets users choose one option from a list in a dropdown.Not tracked
Status reflects the component tracker snapshot of 29 October 2026.