# Toolbar

A keyboard-navigable collection of related controls with semantic surfaces.

A keyboard-navigable collection of related controls on a neutral card surface. Toolbar styling follows the design-system Toolbar spec: 32px controls, subtle gray inputs, vertical dividers, and toggle-like pressed treatment for `aria-pressed` buttons.

<p className="zenos-base-ui-source">
  Backed by <a href="https://base-ui.com/react/components/toolbar">Base UI Toolbar</a> for upstream
  behavior and configuration. Zenos owns the public API, styling, and composition shown on this
  page.
</p>

```tsx
import { TextBIcon, TextItalicIcon, TextUnderlineIcon } from "@phosphor-icons/react";
import { Stack, Toolbar } from "@zentara-co/zenos-ui";

function ToolbarExample() {
  return (
    <Stack direction="row" justify="center" className="w-full">
      <Toolbar.Root aria-label="Editor">
        <Toolbar.Group aria-label="Formatting">
          <Toolbar.Button aria-label="Bold">
            <TextBIcon aria-hidden />
          </Toolbar.Button>
          <Toolbar.Button aria-label="Italic">
            <TextItalicIcon aria-hidden />
          </Toolbar.Button>
          <Toolbar.Button aria-label="Underline">
            <TextUnderlineIcon aria-hidden />
          </Toolbar.Button>
        </Toolbar.Group>
        <Toolbar.Separator />
        <Toolbar.Input aria-label="Document title" placeholder="Input" />
        <Toolbar.Separator />
        <Toolbar.Link href="#history">History</Toolbar.Link>
      </Toolbar.Root>
    </Stack>
  );
}
```

```tsx
import { Toolbar } from "@zentara-co/zenos-ui";
```

## Composition

Combine icon buttons, text buttons, inputs, links, groups, and separators in one roving-focus collection. Icon-only controls need `aria-label`. Text and icon children use the same automatic padding rules as [`Toggle`](/components/toggle/).

```tsx
import { MagnifyingGlassMinusIcon, MagnifyingGlassPlusIcon } from "@phosphor-icons/react";
import { Stack, Toolbar } from "@zentara-co/zenos-ui";
import { useState } from "react";

function ToolbarSearchExample() {
  const [filterPressed, setFilterPressed] = useState(true);

  return (
    <Stack direction="row" justify="center" className="w-full">
      <Toolbar.Root aria-label="Search tools">
        <Toolbar.Button aria-label="Zoom in">
          <MagnifyingGlassPlusIcon aria-hidden />
        </Toolbar.Button>
        <Toolbar.Button aria-label="Zoom out">
          <MagnifyingGlassMinusIcon aria-hidden />
        </Toolbar.Button>
        <Toolbar.Separator />
        <Toolbar.Input aria-label="Search" placeholder="Search" />
        <Toolbar.Separator />
        <Toolbar.Button
          aria-pressed={filterPressed}
          onClick={() => setFilterPressed((value) => !value)}
        >
          Filter
        </Toolbar.Button>
      </Toolbar.Root>
    </Stack>
  );
}
```

## Buttons and inputs

Default toolbar buttons use a transparent ghost surface with neutral hover. Set `aria-pressed` for a red selected treatment (for example a sticky filter). `Toolbar.Input` uses the subtle gray field and defaults to `w-60`. Other Button variants (`primary`, `outline`, …) remain available when a control needs stronger emphasis.

```tsx
import { Toolbar } from "@zentara-co/zenos-ui";
import { useState } from "react";

function ToolbarControlsExample() {
  const [query, setQuery] = useState("");

  return (
    <Toolbar.Root aria-label="Asset actions" className="max-w-full">
      <Toolbar.Group aria-label="Primary actions">
        <Toolbar.Button variant="primary">Create</Toolbar.Button>
        <Toolbar.Button variant="ghost">Refresh</Toolbar.Button>
        <Toolbar.Button variant="ghost" disabled>
          Archive
        </Toolbar.Button>
      </Toolbar.Group>
      <Toolbar.Separator />
      <Toolbar.Input
        aria-label="Filter assets"
        value={query}
        onChange={(event) => setQuery(event.target.value)}
        placeholder="Filter assets"
      />
      <Toolbar.Separator />
      <Toolbar.Link href="#toolbar-api">API</Toolbar.Link>
    </Toolbar.Root>
  );
}
```

## Orientation

Horizontal toolbars use Left and Right Arrow. Vertical toolbars stack full-width, centered items and use Up and Down Arrow. Separator orientation follows the toolbar automatically.

```tsx
import { TextBIcon, TextItalicIcon } from "@phosphor-icons/react";
import { Stack, Toolbar } from "@zentara-co/zenos-ui";

function ToolbarOrientationExample() {
  return (
    <Stack direction="row" gap="8" align="start" justify="center" wrap="wrap" className="w-full">
      <Toolbar.Root aria-label="Horizontal editor tools">
        <Toolbar.Button aria-label="Bold">
          <TextBIcon aria-hidden />
        </Toolbar.Button>
        <Toolbar.Button aria-label="Italic">
          <TextItalicIcon aria-hidden />
        </Toolbar.Button>
        <Toolbar.Separator />
        <Toolbar.Button>Comment</Toolbar.Button>
      </Toolbar.Root>

      <Toolbar.Root orientation="vertical" aria-label="Vertical block tools">
        <Toolbar.Button>Move Up</Toolbar.Button>
        <Toolbar.Button>Move Down</Toolbar.Button>
        <Toolbar.Separator />
        <Toolbar.Button variant="destructive">Delete</Toolbar.Button>
      </Toolbar.Root>
    </Stack>
  );
}
```

## Groups

Group controls that perform related work and name each group when that relationship is useful to assistive technology. Separators provide visual boundaries between groups.

```tsx
import { TextBIcon, TextItalicIcon } from "@phosphor-icons/react";
import { Stack, Toolbar } from "@zentara-co/zenos-ui";

function ToolbarGroupsExample() {
  return (
    <Stack direction="row" justify="center" className="w-full">
      <Toolbar.Root aria-label="Document editor">
        <Toolbar.Group aria-label="Text formatting">
          <Toolbar.Button aria-label="Bold">
            <TextBIcon aria-hidden />
          </Toolbar.Button>
          <Toolbar.Button aria-label="Italic">
            <TextItalicIcon aria-hidden />
          </Toolbar.Button>
        </Toolbar.Group>
        <Toolbar.Separator />
        <Toolbar.Group aria-label="Clipboard">
          <Toolbar.Button>Copy</Toolbar.Button>
          <Toolbar.Button>Paste</Toolbar.Button>
        </Toolbar.Group>
      </Toolbar.Root>
    </Stack>
  );
}
```

## Custom styling

Every Toolbar part accepts `className`. Style a part directly, or scope a cohesive treatment from `Toolbar.Root` with the stable `data-slot` attributes. Keep orientation, pressed state, labels, and other behavior expressed through their dedicated props and native attributes.

```tsx
import { TextBIcon, TextItalicIcon } from "@phosphor-icons/react";
import { Stack, Toolbar } from "@zentara-co/zenos-ui";

function ToolbarCustomStylingExample() {
  return (
    <Stack direction="row" justify="center" className="w-full">
      <Toolbar.Root
        aria-label="Branded editor tools"
        className="rounded-full border-border-accent-purple-default bg-background-accent-purple-subtlest-default p-2 shadow-raised [&_[data-slot=toolbar-button]]:rounded-full [&_[data-slot=toolbar-button]]:text-text-accent-purple-bolder [&_[data-slot=toolbar-button]]:hover:bg-background-accent-purple-subtlest-hover [&_[data-slot=toolbar-button][aria-pressed=true]]:bg-background-accent-purple-subtlest-pressed [&_[data-slot=toolbar-input]]:w-44 [&_[data-slot=toolbar-input]]:rounded-full [&_[data-slot=toolbar-input]]:bg-background-neutral-card [&_[data-slot=toolbar-separator]]:bg-border-accent-purple-default"
      >
        <Toolbar.Group aria-label="Text formatting">
          <Toolbar.Button aria-label="Bold" aria-pressed>
            <TextBIcon aria-hidden />
          </Toolbar.Button>
          <Toolbar.Button aria-label="Italic">
            <TextItalicIcon aria-hidden />
          </Toolbar.Button>
        </Toolbar.Group>
        <Toolbar.Separator />
        <Toolbar.Input aria-label="Find in document" placeholder="Find in document" />
      </Toolbar.Root>
    </Stack>
  );
}
```

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| orientation | 'horizontal' \| 'vertical' | horizontal | Layout and arrow-key navigation direction. |
| variant (Button / Link) | ButtonVariant | ghost | Ghost and destructive use toolbar-native surfaces; other values reuse Button styles. |
| size (Button / Link) | 'sm' \| 'md' \| 'lg' | sm | Applies when using non-toolbar Button variants. |
| aria-pressed (Button) | boolean | — | Shows the red selected toolbar treatment. |

## Anatomy

```text
Toolbar.Root
Toolbar.Group
Toolbar.Button
Toolbar.Link
Toolbar.Input
Toolbar.Separator
```

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| orientation | horizontal \| vertical | horizontal | Toolbar navigation axis. |
| variant | ButtonVariant | ghost | Ghost and destructive use Toolbar surfaces; other values reuse Button styling. |
| size | sm \| md \| lg | sm | Button and link size when using Button variants. |
| render | ReactElement \| function | — | Composes toolbar links or buttons. |
| loopFocus | boolean | true | Wraps roving focus at the first and last controls. |
| native props | React.Base UI Toolbar props | — | Forwards native attributes, events, aria-*, data-*, className, style, and ref. |

Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props, including className, style, aria-*, and data-*.

## Accessibility

Give every toolbar an accessible name and every icon-only control a specific label. Base UI manages roving focus, skips disabled controls, loops by default, and uses Home and End to reach the first and last available item. Tab enters or leaves the toolbar as one stop; arrow keys move within it.

Source: https://zenos-ui.pages.dev/components/toolbar/