NavMenu

A hierarchical site navigation panel with active-page state, collapsible groups and optional search and account controls.

NavMenu

View source · API reference

On a PureStack site you rarely configure NavMenu at all: the doc layout docks it in the sidebar and fills it from the site navigation. Reach for its props when the menu lives somewhere else, needs its own items, or should take on a different treatment.

Playground

Switch between a documentation tree and an application menu, then pick the current page. The current page is marked for assistive technology and every group above it opens. Choose a link in the menu to move there; the playground keeps links on this page. Glass reads best on the spotlight backdrop it was designed for.

From site config

The menu the doc layout docks in its sidebar takes its tone, variant and extra classes from the navigation section of siteConfig.json. A page can still override the tone with nav.tone in its frontmatter.

{
  "navigation": {
    "tone": "accent",
    "variant": "glass",
    "class": "spotlight-from-top-right"
  }
}

Docked in the sidebar, the menu stays square and borderless whatever the variant, so the variant sets its fill and colors.

Your own items

Pass items to show a tree that is not the site navigation, and currentUrl to say which page is current. Without currentUrl, NavMenu uses the page being rendered, then the browser location. Groups are items with children; a group can have its own url too.

<NavMenu
  currentUrl="/app/billing/invoices/"
  variant="surfaceAlt"
  :items="[
    { title: 'Dashboard', url: '/app/', icon: 'tabler:layout-dashboard' },
    {
      title: 'Billing',
      icon: 'tabler:credit-card',
      children: [
        { title: 'Invoices', url: '/app/billing/invoices/' },
        { title: 'Plans', url: '/app/billing/plans/' },
      ],
    },
  ]"
/>

In a client-side app, pass a shallow sref for items and a ref for currentUrl. The menu redraws when either changes. A deep ref would turn every item into a ref of its own.

Docked in the doc layout

This preview renders the menu exactly as the SSG does: from the site navigation, in its own document with the standard runtime. The current page opens its ancestor group. Expand Layout to inspect another branch; links open the real guides within the preview.

Behavior and accessibility

NavMenu is a nav landmark labelled “Site navigation”. The current page’s link carries aria-current="page" and every group above it starts open. Groups are native details and summary, so they open and close from the keyboard without script, and visitors who never run script still see the whole tree.

With the standard navigation runtime, a menu remembers which groups were open and where it was scrolled. Docked in the doc layout’s sidebar, it also gains the layout controls: collapsing to a rail, reopening as a floating panel, and dragging its edge to resize. A menu anywhere else, like the one in the playground, stays plain navigation and never changes the page layout.

Use NavList when you already have prepared row state and need only the list.

API reference

NavMenu contract

Items, current page, tone and treatment are reactive. The SSG context supplies the default navigation, current URL, search configuration and authentication configuration.

Composition

No slots. Register defineNavigationComponents with BtnLink, Icon, SignIn and SearchBox dependencies. NavItem is an internal row component that reads its item from the surrounding list context.