Toolbar
The unified window toolbar: a title, Liquid Glass button groups and a search field.
@cupertinoui-pro/toolbarCupertinoUI Pro"use client"
import * as React from "react"
import {
ChevronLeftIcon,
ChevronRightIcon,
Columns3Icon,
LayoutGridIcon,
ListIcon,
ShareIcon,
} from "lucide-react"
import { SearchField } from "@/components/ui/search-field"
import {
Toolbar,
ToolbarSpacer,
ToolbarTitle,
} from "@/components/ui/toolbar"
import {
ToolbarButton,
ToolbarButtonGroup,
ToolbarButtonGroupSeparator,
} from "@/components/ui/toolbar-button-group"
import {
Window,
WindowContent,
WindowControls,
WindowMain,
} from "@/components/ui/window"
export default function ToolbarDemo() {
const [view, setView] = React.useState("grid")
return (
<Window className="h-60 w-full max-w-2xl">
<WindowMain>
<Toolbar>
<WindowControls className="mx-3" />
<ToolbarButtonGroup>
<ToolbarButton aria-label="Back">
<ChevronLeftIcon className="size-5" />
</ToolbarButton>
<ToolbarButtonGroupSeparator />
<ToolbarButton aria-label="Forward" disabled>
<ChevronRightIcon className="size-5" />
</ToolbarButton>
</ToolbarButtonGroup>
<ToolbarTitle title="Projects" />
<ToolbarSpacer />
<ToolbarButtonGroup
type="single"
value={view}
onValueChange={setView}
aria-label="View"
className="max-sm:hidden"
>
<ToolbarButton value="grid" aria-label="Icons">
<LayoutGridIcon strokeWidth={1.6} />
</ToolbarButton>
<ToolbarButton value="list" aria-label="List">
<ListIcon strokeWidth={1.6} />
</ToolbarButton>
<ToolbarButton value="columns" aria-label="Columns">
<Columns3Icon strokeWidth={1.6} />
</ToolbarButton>
</ToolbarButtonGroup>
<ToolbarButtonGroup>
<ToolbarButton aria-label="Share">
<ShareIcon strokeWidth={1.6} />
</ToolbarButton>
</ToolbarButtonGroup>
<SearchField variant="glass" size="xl" className="w-40 max-md:hidden" aria-label="Search" />
</Toolbar>
<WindowContent className="flex items-center justify-center bg-mac-content text-mac-label-secondary">
Viewing as {view}
</WindowContent>
</WindowMain>
</Window>
)
}Installation
pnpm dlx shadcn@latest add @cupertinoui-pro/toolbarPart of CupertinoUI Pro: the CLI installs it with your license key, once the @cupertinoui-pro registry is in components.json.
Usage
import { Toolbar, ToolbarSpacer, ToolbarTitle } from "@/components/ui/toolbar"
import {
ToolbarButton,
ToolbarButtonGroup,
} from "@/components/ui/toolbar-button-group"
<Toolbar>
<ToolbarTitle title="Projects" />
<ToolbarSpacer />
<ToolbarButtonGroup>
<ToolbarButton aria-label="Share">
<ShareIcon />
</ToolbarButton>
</ToolbarButtonGroup>
</Toolbar>Toolbar buttons have no background of their own: put them in a Toolbar Button Group, the Liquid Glass capsule. Several buttons in one group share a capsule, and a group can work like radio buttons for a view switcher.
API Reference
Every part forwards the props of the underlying element. The props below are the ones CupertinoUI adds or changes.
Toolbar
The 52pt unified toolbar.
| Prop | Type | Description |
|---|---|---|
className | string | Extra classes, merged with the component's own. |
ToolbarTitle
| Prop | Type | Description |
|---|---|---|
title | ReactNode | The window title, 15pt semibold. |
subtitle | ReactNode | Optional second line. |
ToolbarSpacer
Pushes the items after it to the right.
| Prop | Type | Description |
|---|---|---|
className | string | Extra classes, merged with the component's own. |