# Navigation menu

Site navigation with grouped links and responsive dropdowns.

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

## When to use

- Use it when a page needs site navigation with grouped links and responsive dropdowns.
- 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 navigation menu.

## 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 Navigation menu

```sh
npx shadcn@latest add @tidal-pro/navigation-menu
```

Stylesheets: `components/ui/tidal.css`, `components/ui/navigation-menu.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/navigation-menu.css";
import{TidalNavigationMenu}from"./components/ui/navigation-menu";
export default()=><div className="tidal-scope"><TidalNavigationMenu items={[{kind:"link",id:"example",label:"Demo",href:"#"}]} label={"Demo"}/></div>;
```

## Structured props

- `TidalNavigationMenu.items: ReadonlyArray<TidalNavigationMenuItem>`: Required items value accepted by this exported component.
- `TidalNavigationMenu.label: string`: Required label value accepted by this exported component.
- `TidalNavigationMenu.defaultOpenId?: string | null | undefined` (default null): Optional default open id value accepted by this exported component.
- `TidalNavigationMenu.dir?: "ltr" | "rtl" | undefined` (default "ltr"): Optional dir value accepted by this exported component.
- `TidalNavigationMenu.disabled?: boolean | undefined` (default false): Optional disabled value accepted by this exported component.
- `TidalNavigationMenu.emptyMessage?: ReactNode` (default "No destinations available."): Optional empty message value accepted by this exported component.
- `TidalNavigationMenu.onOpenChange?: ((openId: string | null) => void) | undefined`: Callback invoked when the open change interaction is proposed.
- `TidalNavigationMenu.openId?: string | null | undefined`: Optional open id value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/navigation-menu.tsx) | [Manifest](https://tidalui.com/examples/navigation-menu.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 { useLayoutEffect, useRef, useState, type MouseEvent } from "react";

import { TidalNavigationMenu, type TidalNavigationMenuItem } from "./components/ui/navigation-menu";

import "./components/ui/navigation-menu.css";



const tidalExampleStyles = ".tidal-scope .navigation-menu-demo,\n.tidal-scope .navigation-menu-demo * {\n  box-sizing: border-box;\n}\n\n.tidal-scope .navigation-menu-demo {\n  display: grid;\n  width: min(100%, 720px);\n  min-width: 0;\n  gap: 14px;\n  padding: clamp(8px, 2.5cqi, 20px);\n  color: var(--t-ink);\n  font-family: Inter, ui-sans-serif, system-ui, sans-serif;\n}\n\n.tidal-scope .navigation-menu-demo-preview {\n  display: grid;\n  gap: 7px;\n}\n\n.tidal-scope .navigation-menu-demo-preview > span,\n.tidal-scope .navigation-menu-demo-detail > span {\n  color: inherit;\n  font-size: 10px;\n  font-weight: 750;\n  letter-spacing: 0.09em;\n  line-height: 1.35;\n  text-transform: uppercase;\n}\n\n.tidal-scope .navigation-menu-demo-preview strong {\n  font-size: 19px;\n  font-weight: 630;\n  letter-spacing: -0.025em;\n  line-height: 1.18;\n}\n\n.tidal-scope .navigation-menu-demo-preview p,\n.tidal-scope .navigation-menu-demo-detail p,\n.tidal-scope .navigation-menu-demo-note {\n  margin: 0;\n  overflow-wrap: anywhere;\n}\n\n.tidal-scope .navigation-menu-demo-preview p {\n  color: color-mix(in srgb, var(--t-surface) 72%, transparent);\n  font-size: 11px;\n  line-height: 1.45;\n}\n\n.tidal-scope .navigation-menu-demo-detail {\n  display: grid;\n  min-width: 0;\n  gap: 5px;\n  padding: 18px;\n  background: var(--t-subtle);\n  border: 1px solid var(--t-border);\n  border-radius: 18px;\n}\n\n.tidal-scope .navigation-menu-demo-detail > span {\n  color: var(--t-muted);\n}\n\n.tidal-scope .navigation-menu-demo-detail strong {\n  font-size: clamp(18px, 4cqi, 25px);\n  font-weight: 620;\n  letter-spacing: -0.03em;\n  line-height: 1.18;\n  overflow-wrap: anywhere;\n}\n\n.tidal-scope .navigation-menu-demo-detail p {\n  color: var(--t-muted);\n  font-size: 12px;\n  line-height: 1.5;\n}\n\n.tidal-scope .navigation-menu-demo-note {\n  padding-top: 10px;\n  color: var(--t-muted);\n  border-top: 1px solid var(--t-border);\n  font-size: 11px;\n  line-height: 1.45;\n}";

const descriptions: Record<string, string> = {
  analytics: "Revenue, retention and product signals.",
  automations: "Rules that keep routine work moving.",
  inbox: "One place for customer conversations.",
  guides: "Practical setup notes for each workflow.",
  pricing: "Compare the sample plan structure.",
};

function isPlainClick(event: MouseEvent<HTMLAnchorElement>) {
  return (
    event.button === 0 &&
    !event.metaKey &&
    !event.ctrlKey &&
    !event.altKey &&
    !event.shiftKey
  );
}

export function NavigationMenuDemo() {
  const [openId, setOpenId] = useState<string | null>("product");
  const [selected, setSelected] = useState("analytics");
  const detailRef = useRef<HTMLDivElement>(null);
  const selectionFocusIntent = useRef(false);
  const selectedLinkWasFocused = useRef(false);

  useLayoutEffect(() => {
    if (!selectionFocusIntent.current) return;
    selectionFocusIntent.current = false;
    const shouldFocus =
      selectedLinkWasFocused.current ||
      document.activeElement === document.body;
    selectedLinkWasFocused.current = false;
    if (shouldFocus) detailRef.current?.focus({ preventScroll: true });
  }, [selected, openId]);

  function sampleLink(id: string) {
    return (event: MouseEvent<HTMLAnchorElement>) => {
      if (!isPlainClick(event)) return;
      event.preventDefault();
      selectionFocusIntent.current = true;
      selectedLinkWasFocused.current =
        document.activeElement === event.currentTarget;
      setSelected(id);
      setOpenId(null);
    };
  }

  const items: readonly TidalNavigationMenuItem[] = [
    {
      kind: "group",
      id: "product",
      label: "Product",
      description: "Explore workspace tools",
      destinations: [
        {
          id: "analytics",
          label: "Analytics",
          description: descriptions.analytics,
          href: "#navigation-menu-detail",
          active: selected === "analytics",
          anchorProps: { onClick: sampleLink("analytics") },
        },
        {
          id: "automations",
          label: "Automations",
          description: descriptions.automations,
          href: "#navigation-menu-detail",
          active: selected === "automations",
          anchorProps: { onClick: sampleLink("automations") },
        },
        {
          id: "inbox",
          label: "Inbox",
          description: descriptions.inbox,
          href: "#navigation-menu-detail",
          active: selected === "inbox",
          anchorProps: { onClick: sampleLink("inbox") },
        },
      ],
      preview: (
        <div className="navigation-menu-demo-preview">
          <span>Workspace</span>
          <strong>Three connected tools</strong>
          <p>Open a destination to update the local detail below.</p>
        </div>
      ),
    },
    {
      kind: "group",
      id: "resources",
      label: "Resources",
      destinations: [
        {
          id: "guides",
          label: "Guides",
          description: descriptions.guides,
          href: "#navigation-menu-detail",
          active: selected === "guides",
          anchorProps: { onClick: sampleLink("guides") },
        },
      ],
    },
    {
      kind: "link",
      id: "pricing",
      label: "Pricing",
      description: descriptions.pricing,
      href: "#navigation-menu-detail",
      active: selected === "pricing",
      anchorProps: { onClick: sampleLink("pricing") },
    },
  ];

  return (
    <section
      className="navigation-menu-demo"
      aria-label="Navigation menu preview"
    >
      <TidalNavigationMenu
        label="Sample site"
        items={items}
        openId={openId}
        onOpenChange={setOpenId}
      />

      <div
        ref={detailRef}
        id="navigation-menu-detail"
        className="navigation-menu-demo-detail"
        role="region"
        aria-label="Selected destination detail"
        tabIndex={-1}
      >
        <span>Selected destination</span>
        <strong>
          {
            items
              .flatMap((item) =>
                item.kind === "group" ? item.destinations : [item],
              )
              .find((item) => item.id === selected)?.label
          }
        </strong>
        <p>{descriptions[selected]}</p>
      </div>

      <p className="navigation-menu-demo-note">
        Sample navigation. Selection changes only this preview.
      </p>
    </section>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <NavigationMenuDemo />
    </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 native nav landmark. items is an ordered list of direct native links and disclosure groups with unique IDs, ReactNode labels and descriptions, native anchor or trigger attributes, individual refs, disabled state, active destination state, nested destinations and optional consumer-owned preview content. openId/onOpenChange support controlled disclosure; defaultOpenId supports uncontrolled disclosure. Accepted plain primary destinations close the open disclosure while modified clicks, downloads and non-self targets retain native behavior. Caller prevention runs before owned trigger, key and link behavior. Escape closes and returns focus to the group trigger; ArrowDown opens a group or focuses its first enabled destination, and ArrowUp/Down/Home/End traverse enabled destinations without replacing ordinary Tab order. dir controls logical RTL behavior. disabled resolves every trigger and destination to native or ARIA-disabled behavior. emptyMessage accepts ReactNode, including numeric zero. The forwarded ref and remaining native attributes target the nav root. Consumers own destinations, previews, disclosure decisions, active state and navigation outcomes.
