Components

Navigation Menu

A site's top navigation as a strip of index dividers: pencil-sketched tabs standing on a pencil line, the open one lifted and washed with highlighter, the current page filled. Its panel drops from under the strip as a slip of paper that follows the size of what is inside, and a felt-tip underline slides along to the open tab. Hover intent, arrow keys and the motion between panels are Radix's.

Install

terminal
npx shadcn@latest add @wobko/navigation-menu

First time here? Add the registry to components.json first. How to install

Examples

Getting started

The shadcn demo on an index strip: a featured card with the mascot beside three rows, a two-column panel of components, and a plain tab. Move from Getting started to Components: the slip resizes, the panels slide inside it and the felt-tip underline glides along.

Links only

No panels: a strip of links. In the strip a link is a tab like the triggers, and the current page (active) is filled with highlighter with aria-current. Arrow keys walk the tabs; asChild puts the tab on your router's link.

A slip under each tab

viewport={false}: there is no shared slip, so each panel is a slip of its own set down under its tab, at the size of its contents. Good for short menus of a few links.

Site header (composed)

A real use: the logo, the strip and the account buttons in one header on a sheet of paper. The panels open over the page below; the sign-in button is a normal Button.

Six items (as written)

shadcn's `navigation-menu-demo` line for line: `viewport={isMobile}` from `useIsMobile()`, `navigationMenuTriggerStyle()` on a plain link, `flex-wrap` on the list, the last three panels hidden below `md`, and a ListItem helper. Link is an `<a>` here (shadcn's uses next/link).

API reference

NavigationMenu

The Radix root (`nav`). Renders the shared viewport slip after its children unless told not to. The panel is not portalled: it hangs from the strip, so its `z-index` counts inside the nearest stacking context. Inside a Paper, a card or any other isolated header, give that element a z-index (`z-(--ll-z-raised)`) so the panel drops over the content that follows it.

PropTypeDefaultDescription
viewportbooleantrueOne slip shared by every panel, resized to the open one (and the panels slide inside it). `false`: each panel is a slip of its own set down under its tab.
value / defaultValue / onValueChangestring / string / (value: string) => void-Which item is open.
delayDuration / skipDelayDurationnumber200 / 300Hover intent, in ms.
dir / orientation-Radix's. The tabs, arrows and drawings follow the reading direction.

NavigationMenuTrigger

A tab that opens a panel (a button, `aria-expanded`). Its drawing: a faint pencil sketch at rest, highlighter and felt under the pointer, lifted with a wash while open. The chevron turns over when it opens.

PropTypeDefaultDescription
seedstring | number-Pins the hand: the same seed always draws the same tab. Default: from useId().
disabledbooleanfalseA dashed pencil tab that does not open.

NavigationMenuLink

A link. Inside a panel it is a row that wears the highlighter (the current one stays on it). In the strip itself it is a tab, like the triggers, and the current page (`active`) is filled with highlighter: pass `asChild` to use your router's link. Inside a panel every svg without a `size-*` class is drawn 16 px (the icon rule), so give art such as a Mascot an explicit size.

PropTypeDefaultDescription
activebooleanfalseThe current page: `aria-current="page"`, `data-active`, and the filled tab.
asChildbooleanfalseRender your link; the tab's drawing lands inside it.
seedstring | number-Pins the hand of a tab link.

Accessibility

  • Radix NavigationMenu: a `nav` landmark (give it `aria-label`), a list of items, triggers with `aria-expanded` and `aria-controls`. It is a disclosure pattern, not `role=menu`: panels hold ordinary links.
  • Hover (with intent delay), click and Enter or Space open a panel; Escape closes it and returns focus to its trigger. Left and Right (mirrored in RTL) move between triggers and links, ArrowDown from an open trigger steps into the panel, and Tab moves through the panel's links and on. Focus leaving the menu closes it.
  • The current page is `aria-current="page"` and a filled tab, so it does not depend on color. The sketches, the pencil line, the underline and the highlighter are aria-hidden decoration with no pointer events. Tabs are 36 px high (32 compact, 28 calm).
  • Touch: a tap opens a panel (hover is not needed). Reduced motion removes the drop, the slide between panels and the underline's glide. In forced-colors mode the drawings give way to real outlines.

Source

The files the CLI copies into your project.

Loading the source