# Toolbar

A native action toolbar with roving keyboard focus and an explicit overflow menu handoff.

Access: pro. Category: Navigation. Kind: composite.

## When to use

- Use it when a page needs a native action toolbar with roving keyboard focus and an explicit overflow menu handoff.
- Choose it as the nav region when composing a page from independently reusable TidalUI sections.

## Alternatives

- Choose navigation-bar instead when responsive saas navigation with native links, actions and an in-flow mobile disclosure is the actual interface need, rather than toolbar.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install Toolbar

```sh
npx shadcn@latest add @tidal-pro/toolbar
```

Stylesheets: `components/ui/tidal.css`, `components/ui/toolbar.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/toolbar.css";
import{TidalToolbar}from"./components/ui/toolbar";
export default()=><div className="tidal-scope"><TidalToolbar items={[{id:"example",label:"Demo",onAction:() => {}}]} label={"Demo"}/></div>;
```

## Structured props

- `TidalToolbar.items: ReadonlyArray<TidalToolbarItem>`: Required items value accepted by this exported component.
- `TidalToolbar.label: string`: Required label value accepted by this exported component.
- `TidalToolbar.dir?: "ltr" | "rtl" | undefined` (default "ltr"): Optional dir value accepted by this exported component.
- `TidalToolbar.disabled?: boolean | undefined` (default false): Optional disabled value accepted by this exported component.
- `TidalToolbar.emptyMessage?: ReactNode` (default "No actions available."): Optional empty message value accepted by this exported component.
- `TidalToolbar.loop?: boolean | undefined` (default true): Optional loop value accepted by this exported component.
- `TidalToolbar.orientation?: "horizontal" | "vertical" | undefined` (default "horizontal"): Optional orientation value accepted by this exported component.
- `TidalToolbar.overflowAccessibleLabel?: string | undefined` (default "More actions"): Optional overflow accessible label value accepted by this exported component.
- `TidalToolbar.overflowIds?: ReadonlyArray<string> | undefined` (default []): Optional overflow ids value accepted by this exported component.
- `TidalToolbar.overflowLabel?: ReactNode` (default "More"): Optional overflow label value accepted by this exported component.
- `TidalToolbar.overflowTriggerProps?: (Omit<TidalToolbarButtonProps, "onKeyDown" | "onClick"> & { onClick?: ButtonHTMLAttributes<HTMLButtonElement>["onClick"]; onKeyDown?: ButtonHTMLAttributes<HTMLButtonElement>["onKeyDown"]; }) | undefined`: Optional overflow trigger props value accepted by this exported component.
- `TidalToolbar.overflowTriggerRef?: Ref<HTMLButtonElement> | undefined`: Optional overflow trigger ref value accepted by this exported component.
- `TidalToolbar.portalContainer?: HTMLElement | null | undefined`: Optional portal container value accepted by this exported component.
- `TidalToolbar.theme?: "light" | "dark" | undefined` (default "light"): Optional theme value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/toolbar.tsx) | [Manifest](https://tidalui.com/examples/toolbar.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
"use client";

import "./components/ui/tidal.css";

import { useState } from "react";

import { TidalToolbar, type TidalToolbarItem } from "./components/ui/toolbar";

import "./components/ui/toolbar.css";



const tidalExampleStyles = ".tidal-scope .toolbar-demo,\n.tidal-scope .toolbar-demo * {\n  box-sizing: border-box;\n}\n\n.tidal-scope .toolbar-demo {\n  display: grid;\n  width: min(100%, 620px);\n  min-width: 0;\n  gap: 12px;\n}\n\n.tidal-scope .toolbar-demo-text {\n  min-height: 108px;\n  padding: 24px;\n  color: var(--t-ink);\n  background: var(--t-surface);\n  border: 1px solid var(--t-border);\n  border-radius: 18px;\n  box-shadow: 0 18px 40px -38px #0000008c;\n  font-size: clamp(18px, 4cqi, 27px);\n  letter-spacing: -0.025em;\n  line-height: 1.35;\n  overflow-wrap: anywhere;\n  transition:\n    font-weight 160ms var(--t-ease-out),\n    letter-spacing 160ms var(--t-ease-out);\n}\n\n.tidal-scope .toolbar-demo-text[data-align=\"center\"] {\n  text-align: center;\n}\n\n.tidal-scope .toolbar-demo-status {\n  margin: 0;\n  color: var(--t-muted);\n  font-size: 11px;\n  line-height: 1.5;\n  text-align: center;\n  overflow-wrap: anywhere;\n}\n\n@media (max-width: 390px) {\n  .tidal-scope .toolbar-demo-text {\n    min-height: 96px;\n    padding: 18px;\n    font-size: 19px;\n  }\n\n  .tidal-scope .toolbar-demo-status {\n    font-size: 12px;\n  }\n}\n\n@media (prefers-reduced-motion: reduce) {\n  .tidal-scope .toolbar-demo-text {\n    transition: none;\n  }\n}";

export function ToolbarDemo({ theme = "light" }: { theme?: "light" | "dark" }) {
  const [bold, setBold] = useState(false);
  const [italic, setItalic] = useState(false);
  const [alignment, setAlignment] = useState<"left" | "center">("left");
  const [status, setStatus] = useState("Formatting is ready.");

  const reset = () => {
    setBold(false);
    setItalic(false);
    setAlignment("left");
    setStatus("Formatting cleared.");
  };

  const items: TidalToolbarItem[] = [
    {
      id: "bold",
      label: "Bold",
      icon: <b>B</b>,
      pressed: bold,
      onAction: () => {
        setBold((value) => !value);
        setStatus(`Bold ${bold ? "off" : "on"}.`);
      },
    },
    {
      id: "italic",
      label: "Italic",
      icon: <i>I</i>,
      pressed: italic,
      separatorAfter: true,
      onAction: () => {
        setItalic((value) => !value);
        setStatus(`Italic ${italic ? "off" : "on"}.`);
      },
    },
    {
      id: "align-left",
      label: "Left",
      icon: "≡",
      pressed: alignment === "left",
      onAction: () => {
        setAlignment("left");
        setStatus("Text aligned left.");
      },
    },
    {
      id: "align-center",
      label: "Center",
      icon: "≡",
      pressed: alignment === "center",
      onAction: () => {
        setAlignment("center");
        setStatus("Text centered.");
      },
    },
    {
      id: "clear",
      label: "Clear formatting",
      disabled: !bold && !italic && alignment === "left",
      onAction: reset,
    },
  ];

  return (
    <section className="toolbar-demo" aria-label="Text formatting preview">
      <TidalToolbar
        label="Text formatting"
        items={items}
        overflowIds={["align-left", "align-center", "clear"]}
        overflowLabel="More"
        overflowAccessibleLabel="More text formatting actions"
        theme={theme}
      />

      <div
        className="toolbar-demo-text"
        data-align={alignment}
        style={{
          fontWeight: bold ? 720 : 460,
          fontStyle: italic ? "italic" : "normal",
        }}
      >
        Review the launch notes before Wednesday at 10:00.
      </div>

      <p className="toolbar-demo-status" role="status" aria-live="polite">
        {status} Changes stay in this preview.
      </p>
    </section>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <ToolbarDemo />
    </div>
  );
}

```

## Gotchas

- The host application owns data, validation, persistence, navigation, and service side effects described by this API.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"keyboard":["Tab and Shift+Tab follow the component's native focus order.","Arrow-key behavior follows the exported composite-control implementation.","Escape dismisses the open overlay where the underlying primitive supports dismissal."],"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"Verify focus visibility, text alternatives, contrast, and reduced motion in the final composition."}

label names the required role=toolbar. items are ordered consumer-owned actions with unique IDs, ReactNode labels, optional accessible labels/icons, controlled pressed state, disabled state, neutral or strong emphasis, optional separator, required onAction callback, native button attributes and refs. Native action handlers run first and prevention suppresses onAction; preventing an overflow action also keeps its menu open. Visible actions use one roving tab stop: horizontal Left/Right follows dir, vertical Up/Down follows orientation, Home/End reach edges, loop defaults true, disabled items are skipped, and focused items are revealed only within the toolbar scroll region. overflowIds explicitly moves matching actions into a Radix menu while invalid IDs are ignored; the More trigger joins toolbar roving focus and accepts a label, accessible label, native attributes and ref. Pressed overflow actions use menuitemcheckbox semantics. Radix owns menu focus, Escape and focus return. emptyMessage preserves numeric zero when items is empty. orientation, dir, loop, disabled, theme and portalContainer configure behavior/presentation. Root native div attributes and forwarded ref are preserved while role/label/orientation remain owned. Consumers own action state, responsive overflow selection, form submission, navigation, requests and persistence.
