Skip to content
GitHub (opens in a new tab)

DocsNav

Docs and catalog sidebar only: title, grouped text-only links, optional decorative icons and muted counts on group and subgroup headers only, an active page pill and optional footer links. Not product chrome, which is SideNav; AppNav is its deprecated alias.

stableOrganismcontracts/docsnav.json

Preview

DocsNav

Vertical sidebar for the docs catalog: text-only rows, a grouped catalog or a flat list. For product chrome use SideNav. Not AppHeader. Formerly AppNav.

Master

Groups collapse one at a time. Active leaf uses aria-current=page.

Usage

Use for a docs or catalog sidebar only. Product app chrome is SideNav. Use NavigationMenu for horizontal site nav. Use Tabs for in-page panels.

Do's

  • Docs, playground or catalog sites with a persistent left sidebar
  • Grouped docs/catalog IA (foundations, components, patterns)
  • List-detail docs layouts with a small flat list of section links
  • Text-only links: small group labels and 14px links; optional decorative icons and muted counts on group and subgroup headers only

Don'ts

  • In-page panel switching — use Tabs
  • Horizontal site nav — use NavigationMenu
  • Breadcrumb trails — not supported
  • Product chrome of any kind (closeable, icon rail, leading icons, badges, account card) — use SideNav
  • Product top bar with logo and search — use AppHeader
<DocsNav title="Nistha" groups={[{ label: 'Components', items: [{ href: '/components#button', label: 'Button', active: true }] }]} />

Component variables

Override on :root, a wrapper, or the component's className / style, e.g. .myNav { --docsnav-width: var(--layout-sidebar); }. Set them to semantic tokens, never hex. Listed under cssVars in the contract.

VariableControls (default)
--docsnav-widthNav width (calc(layout-sidebar + space-2 × 2), 15rem)
--docsnav-paddingInner padding (space-4)
--docsnav-backgroundBackground (surface-card)
--docsnav-item-gapGap between groups, rows and sub-rows (space-1)
--docsnav-item-paddingPadding of links, group toggles and subgroup labels (space-2 space-3)
--docsnav-item-radiusLink corners (radius-control-md)
--docsnav-item-active-backgroundActive link fill (action-primary at 10% over surface-card)
--docsnav-item-active-textActive link text (action-primary)

When to use

  • Docs, playground or catalog sites with a persistent left sidebar
  • Grouped docs/catalog IA (foundations, components, patterns)
  • List-detail docs layouts with a small flat list of section links
  • Text-only links: small group labels and 14px links; optional decorative icons and muted counts on group and subgroup headers only

When not to use

  • In-page panel switching — use Tabs
  • Horizontal site nav — use NavigationMenu
  • Breadcrumb trails — not supported
  • Product chrome of any kind (closeable, icon rail, leading icons, badges, account card) — use SideNav
  • Product top bar with logo and search — use AppHeader

What an agent reads

import { DocsNav } from "agentic-ds-kit";
must
  • nav has aria-label
  • Group labels are disclosure buttons with aria-expanded
  • Subgroup labels are disclosure buttons with aria-expanded
  • Closed group lists are aria-hidden and inert
  • Active leaf uses aria-current=page
  • All leaves are keyboard-focusable links
  • Same-page hash links push a history entry via history.pushState (not location.hash), fire hashchange and scroll the target into view, so Back/Forward stay in sync in Next App Router; cross-page and modified (cmd/ctrl/shift/alt, middle) clicks keep default Link behaviour
  • Footer external links come from kit Link external: new tab, aria-hidden icon, visually hidden "(opens in a new tab)"
  • Motion: the hover fill and the current-page pill are two decorative layers (aria-hidden) that glide between rows (clip-path only, --motion-expand-*): the hover fill follows the pointer and keyboard focus over links and group headers; the pill moves when the active page changes. First paint, a reveal, the pointer leaving and layout shifts (a group opening above) place them at once; until they mount each row paints its own fill. Rows never scale or move on press. Groups open and close on --motion-expand-*, but not before the nav has painted once, so a restored open state lands without a slide. Under prefers-reduced-motion the layers jump with no slide and group height/opacity settle at once; hover colour fades stay. aria-current, roles and focus order are unchanged and the focus ring stays on the link
defaults
Nothing extra in the contract.
stops if
  • Do not invent local Sidebar, AppNav or DocsNav
  • Do not invent Sidebar, SidebarProvider, or local nav chrome — use SideNav
  • Do not import AppNav in new code — it is a deprecated alias of DocsNav; --appnav-* variables are deprecated aliases of --docsnav-*
  • Decorative icons and muted counts only on group/subgroup headers; no icons or badges on leaf items
  • Do not use raw hex
  • Do not use DocsNav for tab panels — use Tabs
  • Do not nest more than one subgroup level
  • Do not set component variables to raw hex or primitive --color-* ramps — use semantic tokens

From contracts/docsnav.json: must is the a11y requirements, defaults the prop defaults, stops if the doNot rules where the agent asks instead of inventing a cousin.

Props

NameTypeRequiredDefaultNotes
titlestringNo——
itemsarrayNo—Flat list for simple shells. Ignored when groups is provided.
groupsarrayNo—Grouped catalog nav. Takes precedence over items when present. Groups collapse. Without openGroups it is an accordion: one group open at a time, the one holding the active page, or the first with defaultOpen. defaultOpen sets the initial group when no leaf is active.
openGroupsstring[]No—Controlled open groups, by label. Any number can be open at once, and the nav never opens or closes a group itself. Pair it with onOpenGroupsChange. Leave it out for the accordion.
onOpenGroupsChangefunctionNo—(openGroups: string[]) => void. Called with the next open labels, in nav order, when a group header is pressed. Used with openGroups.
footerLinksarrayNo—Optional links under a hairline at the bottom of the nav (repo, package, changes), rendered with kit Link variant standalone. external opens a new tab with Link's external icon and "(opens in a new tab)"; others stay in the same tab. Left out, nothing renders.
  • Component
    →

    Tabs

    Switch between related views in place.

  • Component
    →

    NavigationMenu

    Horizontal site nav.

  • Component
    →

    Breadcrumb

    Path to the current page as a hierarchy of links.

  • Component
    →

    SideNav

    Product side nav: brand header, icon items, optional badges, closeable; variant single (one column that closes to an icon rail) or rail-subnav (a fixed icon rail plus a SideNav.SubNav column with the picked parent's rows).