Skip to content
GitHub (opens in a new tab)

SideNav

Product side nav with a brand header and icon items that closes to an icon rail.

stableOrganismcontracts/sidenav.json

Preview

SideNav

Product app chrome side navigation. DocsNav is the docs catalog nav only. Drawer is the overlay panel.

Master

Brand mark, icon items, counts, and a closeable rail. Stays in the layout.

Usage

Put SideNav next to the page. Pass groups of icon items with optional badges. The panel icon closes. The brand mark reopens. Rail corners use radius-surface-md. Item hover, active, and focus fills use radius-control-md. When AppHeader already provides brand, pass showHeader={false} and radius="none" so the column sits flush. Use DocsNav for a docs catalog. Use Drawer for a temporary overlay panel.

A badge of digits renders as a kit Count. A parent with children is a disclosure with a chevron and never takes the page-active fill; the current leaf does. Pass expanded and onExpandedChange to control it. Arrow Down and Up move through the visible rows, Right opens a parent and Left closes it.

Do's

  • Product app chrome
  • Persistent nav with icons

Don'ts

  • Docs catalog — use DocsNav
  • Overlay task panel — use Drawer
  • Centered short task — use Modal
  • Horizontal site nav — use NavigationMenu
  • Product top bar with logo and search — use AppHeader
  • Panels switched in place inside one page or Card — use Tabs orientation="vertical"
<SideNav
  title="Agentix"
  markIcon={<Logo />}
  markSurface="none"
  open={open}
  onOpenChange={setOpen}
  groups={groups}
  footer={footer}
/>

Component variables

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

VariableControls (default)
--sidenav-widthOpen width of the rail and its inner panel (layout-sidebar)
--sidenav-width-collapsedClosed rail width (layout-sidebar-compact). AppHeader's brand column follows it unless --appheader-brand-width is set, so set it on :root to move both
--sidenav-backgroundPanel background (surface-card)
--sidenav-dividerRule on the inline end of a flush rail (radius none), a border shorthand: default border-divider solid border-faint. none for a nav on the canvas (layout-shell--inset sets it)
--sidenav-item-paddingRow padding; sets row height and the closed-rail icon chip (space-inset-sm)
--sidenav-item-radiusRow and closed-rail chip corners (radius-control-md)
--sidenav-item-gapGap between rows, top level and submenu (space-stack-2xs)
--sidenav-item-hover-backgroundRow hover fill (surface-muted)
--sidenav-item-active-backgroundActive row fill, closed-rail current chip and active text badge fill (bg-tray, a neutral grey; hover stays surface-muted)
--sidenav-item-active-textActive row text (text-primary)
--sidenav-item-active-iconActive row icon (icon-brand), so the current row is not marked by the fill alone
--sidenav-group-label-colorGroup label text (text-secondary)

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). Preset props or compose your own from SideNav.Root/Header/Brand/Toggle/Nav/Section/Item/SubNav compose parts. Not DocsNav. Not an overlay itself: on small screens put it inside kit Drawer (the app-shell example shows one way).

When to use

  • Product app chrome
  • Persistent nav with icons

When not to use

  • Docs catalog — use DocsNav
  • Overlay task panel — use Drawer
  • Centered short task — use Modal
  • Horizontal site nav — use NavigationMenu
  • Product top bar with logo and search — use AppHeader
  • Panels switched in place inside one page or Card — use Tabs orientation="vertical"

What an agent reads

import { SideNav } from "agentic-ds-kit";
must
  • In-flow aside, not a dialog and not position:fixed
  • No overlay, no focus trap, no Escape-to-close on the nav itself; the only overlay is the closed-rail flyout below
  • Arrow keys on rows: Down and Up move through visible rows (top level, open submenus, footer), Home and End jump to the first and last; Right on a parent opens it (or moves to its first child when open), Left closes it; Left on a nested row moves to its parent. Right and Left swap in rtl. Tab still moves between rows as usual
  • Closed-rail flyout: a parent row (aria-expanded, aria-controls) opens a panel of its children just outside the rail edge on click, Enter, Space or Right. The panel is a group named by a visible caption (the parent label), portaled, built on the shared overlay dismiss (useOverlayDismiss: Escape and an outside press close it, newest overlay first). Focus moves to its first row; Up, Down, Home and End move; Left (Right in a right-side nav) or Escape closes it and returns focus to the parent; Tab closes it and moves on from the parent; picking a row closes it. Opening the rail closes it
  • A parent that holds the current page shows the same soft chip on the closed rail as the current page, together with aria-expanded and the flyout, so it is not marked by colour alone
  • Close is a kit Button with PanelLeftClose or PanelRightClose and ariaLabel Close
  • Closed rail reopens via the brand mark button (SideNav.Brand) with ariaLabel Open (openLabel); while open the mark is disabled, aria-hidden and out of the tab order
  • Title is visible in the header when open; clipped when closed
  • When showHeader is false, omit the header and close; title remains the accessible name via aria-label
  • Active leaf uses aria-current=page
  • Parent with nested items is a disclosure with aria-expanded
  • Closed rail clips labels via overflow; labels stay in the DOM for assistive tech
  • Outer shell width animates; inner panel stays at layout-sidebar width so icons do not recenter
  • Closed rail trailing border is on the outer shell — the inner panel is clipped
  • Closed rail must not change item width or height — size snaps cause open/close jump
  • Closed rail paints a square chip over the icon; do not clip a full-width row background
  • List items keep space-stack-2xs between rows so selected and hover surfaces do not touch
  • renderItem keeps defaultNode in the tree so aria-current and aria-expanded stay on the row
  • Slot content is inert on the closed rail so clipped controls are not focusable
  • Closed rail: every Item names itself in a kit Tooltip (placed outside the rail edge)
  • SideNav.Toggle stays visible and focusable on the closed rail and reopens it, unless a SideNav.Brand sits in the same header: then the Toggle is hidden there and the mark reopens
  • A user reopen (mark or Toggle, pointer or keyboard) moves focus to the visible Toggle (Close), else the first focusable nav row
  • A user close (Toggle, pointer or keyboard) keeps focus on a control that stays visible (the Toggle at the start edge); if the focused control hides on the closed rail (the Toggle beside a SideNav.Brand), focus moves to the mark (Open), else the closed-rail Toggle
  • Programmatic open changes (controlled open, setOpen without { focus: true }) never move focus; a user request a controlled parent ignores is dropped, so a later programmatic open does not move focus. Custom controls get the same with useSideNav().setOpen(next, { focus: true })
  • Preset with a custom header slot keeps a Toggle, so a closed rail can always be reopened
  • SideNav.Account: long name and secondary truncate but stay whole in the DOM (and the title attribute); the avatar is aria-hidden; the action is an icon Button named by its label; on the closed rail the name is a kit Tooltip on the avatar and the action is inert
  • Inside a kit Drawer, SideNav fills the Drawer body (no rail width, trailing border or card frame) and is always open, so there is no rail to collapse and the Toggle hides
  • rail-subnav: two nav landmarks, the rail (named by the root's aria-label) and SideNav.SubNav (named by its visible caption, the picked parent's label); the column leaves the layout and the accessibility tree while no parent is picked
  • rail-subnav: a rail parent is a button with aria-expanded (it fills the column) and aria-controls (the column); a parent holding the current page takes aria-current=true and the active chip, the current leaf in the column aria-current=page
  • rail-subnav: every rail row names itself in a kit Tooltip (labels stay in the DOM); there is no Toggle and the brand mark is not a control
  • rail-subnav keys: Up, Down, Home and End move within the rail or within the column, never across; Right on a rail parent picks it and moves focus to the column's first row; Left in the column returns to that parent. Right and Left swap in rtl
  • Presence on SideNav.Account is never colour alone: the word joins the name for screen readers and the closed-rail tooltip, and the mark has its own shape
  • Closed rail: a caption turns into a divider but its text stays in the DOM; a collapsed Slot is inert, so nothing hidden can take focus
  • Open rail: the hover fill and the current-page fill are two decorative layers (aria-hidden) inside SideNav.Nav that glide between rows on hover, keyboard focus and a change of the active row (clip-path only, --motion-expand-*); they land in place on first show, after the pointer leaves and on resize or scroll, and jump with no slide under prefers-reduced-motion. The closed rail and the flyout keep their per-row fills. aria-current, roles and focus order are unchanged and the focus ring stays on the row
defaults
  • markSurface brand
  • showHeader true
  • radius md
  • variant single
  • defaultOpen true
  • side left
stops if
  • Do not put an onBrand (white) logo on markSurface="none", or a brand-colour logo on the default brand tile: none takes a logo in brand colour, brand takes a letter, a Lucide name or an onBrand logo
  • Do not invent Sidebar, SidebarHeader, SidebarNav, SidebarSection, SidebarItem, SidebarSubmenu, SidebarFooter, SidebarProvider, SidebarTrigger, SidebarContent, SidebarGroup, SidebarMenu, SidebarMenuItem, SidebarMenuButton, SidebarInset, or SidebarRail
  • Do not hand-build a closed-rail flyout or menu for a parent's children; nested SideNav.Item children already open one on the closed rail
  • Do not hand-roll nav rows (a, button, li with your own active/hover styles) inside SideNav — use SideNav.Item, which carries aria-current, the disclosure attributes and the closed-rail tooltip
  • Do not nest SideNav.Item deeper than one level, or put rows outside a SideNav.Section
  • Do not use SideNav.Root without a SideNav.Toggle or SideNav.Brand in its header when the rail can close — nothing would reopen it
  • Do not compose DocsNav inside SideNav
  • Do not use Drawer for persistent app chrome
  • Do not use DocsNav as closeable product chrome: SideNav is product chrome, DocsNav is the docs/catalog nav only
  • Do not leave a gap between AppHeader and SideNav — radius none, showHeader false, layout-app with no gap
  • Do not give SideNav itself position:fixed, an overlay, a focus trap, or Escape-to-close; on narrow screens render it inside kit Drawer
  • Keep the nav reachable on narrow screens: a kit Button that opens it in kit Drawer (as app-shell does), not a hand-rolled overlay or menu
  • Do not use the shadcn sidebar package
  • Do not use raw hex
  • Do not set component variables to raw hex or primitive --color-* ramps — use semantic tokens
  • Do not hand-build an account card (Avatar + text + Button, or a one-item ListView) in the footer — use account / SideNav.Account
  • Do not borrow AppHeader.Mark / AppHeader.Title for a SideNav brand — use SideNav.Brand, which keeps the mark on the closed rail and reopens it
  • Do not build rail + sub-nav from two SideNav roots or a hand-made second column; use variant="rail-subnav" with SideNav.SubNav
  • Do not place SideNav.SubNav inside SideNav.Nav or a Section; it is a direct child of SideNav.Root

From contracts/sidenav.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
titlestringYes—Brand title in the header. Accessible name on the aside when showHeader is false
markstringNo—Brand letter. Defaults to the first character of title
markIconKitIconNo—Icon mark instead of the letter, on the same brand fill: a Lucide name (e.g. Receipt), a Lucide component, or an element. Wins over mark. AppHeader takes the same prop.
markSurfacebrand | noneNobrandWhat the brand mark sits on; goes to SideNav.Brand. brand: the filled brand tile (fill-brand); use a letter, a Lucide name or an onBrand logo. none: the bare logo on the rail surface, no tile; use an element logo in brand colour (icon-brand). Same on the open and the closed rail.
showHeaderbooleanNotrueBrand mark, title, and close. Set false when AppHeader already provides brand. Rail open/close is controlled by `open`.
radiusmd | noneNomdRail corners. md is radius-surface-md. none is a flush square column next to AppHeader.
variantsingle | rail-subnavNosinglesingle: one column that closes to an icon rail (open, defaultOpen, the Toggle). rail-subnav: the rail is always icons only (each row named in a kit Tooltip) and a parent row fills a SideNav.SubNav column beside it with its nested rows, instead of a disclosure or flyout. Until the user picks, the parent holding the current page fills it; picking the open parent again empties it and the column leaves the layout. open, defaultOpen, onOpenChange and the Toggle are ignored, the brand mark is not a control, and beforeGroups / afterGroups are faded and inert as on the closed rail. Inside a kit Drawer it is always single (expanded, parents are disclosures).
openbooleanNo—controlled
defaultOpenbooleanNotrue—
onOpenChangefunctionNo—(open: boolean) => void
sideleft | rightNoleftDoes not position SideNav. The consumer shell uses row-reverse for right
groupsarrayNo—SideNavGroup[]: { label, items: SideNavItemData[] }. Takes precedence over items
itemsarrayNo—SideNavItemData[] (id, label, href, onClick, icon, active, disabled, badge, items). badge: digits (e.g. "3") render as a kit Count (neutral subtle, brand subtle on the active row) and join the closed-rail tooltip; other text (e.g. "Online") renders as a kit Badge (soft, neutral, sm). icon: a curated Lucide name (any other name needs import "agentic-ds-kit/icons-on-demand") or a Lucide component (client code only; from a Server Component use a name). Flat list when groups is omitted. Leaf onClick is in-app select; href is a link when onClick is omitted.
footerslotNo—SideNavItemData, SideNavItemData[] (e.g. Settings), or any ReactNode. For the signed-in user use account, not a hand-built card.
accountobjectNo—SideNav.Account props. Renders last in the footer, below the footer rows: kit Avatar (sm), name, secondary line (e.g. email), optional trailing tertiary icon Button named by action.label (e.g. Log out). presence puts kit Avatar's corner mark on the avatar; its word (KitLabels online, away, offline) joins the name for screen readers and the closed-rail tooltip (Olivia Rhye, Online). Long text truncates with the full text in the DOM and the hover title.
headerslotNo—Replaces the brand (mark + title) in the header. The preset keeps a SideNav.Toggle beside it: Close while open; on the closed rail the slot fades and goes inert and the Toggle moves to the start edge to reopen the rail. For a mark inside a custom header, build it from compose parts with SideNav.Brand. Ignored when showHeader is false.
beforeGroupsslotNo—Pinned above the scrolling groups, e.g. a workspace switcher. Faded, inert and collapsed to no height on the closed rail.
afterGroupsslotNo—Pinned below the scrolling groups, above the footer, e.g. a promo card. Faded, inert and collapsed to no height on the closed rail.
renderItemfunctionNo—(item, defaultNode) => ReactNode. Customise one row. defaultNode is the kit link or button with aria-current and disclosure attributes: wrap it, put content beside it, or cloneElement it with new children. Keep it in the tree. Applies to nested and footer rows too.
  • Component
    →

    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.

  • Component
    →

    Drawer

    Edge panel for secondary tasks.

  • Component
    →

    Modal

    Dismissible overlay for short tasks, forms, or extra detail.

  • Component
    →

    NavigationMenu

    Horizontal site nav.