Toolbar Button Group

Liquid Glass capsules of toolbar buttons: actions like back and forward, or a set that works like radio buttons, like Finder's view switcher.

@cupertinoui-pro/toolbar-button-groupCupertinoUI ProBase UI Toggle Group

Installation

pnpm dlx shadcn@latest add @cupertinoui-pro/toolbar-button-group

Part of CupertinoUI Pro: the CLI installs it with your license key, once the @cupertinoui-pro registry is in components.json.

Usage

import {
  ToolbarButton,
  ToolbarButtonGroup,
  ToolbarButtonGroupSeparator,
} from "@/components/ui/toolbar-button-group"

<ToolbarButtonGroup>
  <ToolbarButton aria-label="Back">
    <ChevronLeftIcon />
  </ToolbarButton>
  <ToolbarButtonGroupSeparator />
  <ToolbarButton aria-label="Forward">
    <ChevronRightIcon />
  </ToolbarButton>
</ToolbarButtonGroup>

<ToolbarButtonGroup type="single" value={view} onValueChange={setView}>
  <ToolbarButton value="icons" aria-label="as Icons">
    <LayoutGridIcon />
  </ToolbarButton>
  <ToolbarButton value="list" aria-label="as List">
    <ListIcon />
  </ToolbarButton>
</ToolbarButtonGroup>
The capsule is Liquid Glass and works on any background, not only in a Toolbar.
A ToolbarButton has no background of its own; it highlights while hovered or pressed. Give a button with an icon an aria-label.

Examples

Radio

With type="single" the group works like radio buttons, as in Finder's view switcher: exactly one button is selected and sits on a pill, and clicking it again keeps it selected. Dividers appear between unselected buttons.

Toggles

With type="multiple" each button turns on and off by itself.

API Reference

Every part forwards the props of the underlying Base UI Toggle Group part. The props below are the ones CupertinoUI adds or changes.

ToolbarButtonGroup

Without type, a group of plain buttons. With a type, it takes the props of a Base UI Toggle Group.

PropTypeDescription
type"single" | "multiple""single" works like radio buttons: one button is always selected. "multiple" makes every button a toggle.
value / defaultValuestring | string[]The selected value, or values with type="multiple".
onValueChange(value) => voidCalled when the selection changes. With type="single" it never receives an empty value.
classNamestringExtra classes, merged with the component's own.

ToolbarButton

PropTypeDescription
valuestringIdentifies the button in a group with a type.
renderReactElementRender another element, e.g. a link, with the button's styles.
classNamestringExtra classes, merged with the component's own.

ToolbarButtonGroupSeparator

A divider between two plain buttons, e.g. back | forward. Groups with a type draw their own.

PropTypeDescription
classNamestringExtra classes, merged with the component's own.