Navigation Menu

View as Markdown

An app's top links, where some open a panel of pages with a line about each.

Northwind

When to use

An app's top links, where some open a panel of pages with a line about each. Use Sidebar instead when the links run down a sidebar.

Usage

import { NavigationMenu } from "./ui/uicontext/components/NavigationMenu.ts"
export const Main = <M>(h: Html.H<M>, current: string) =>	NavigationMenu(h, {		props: {			label: "Main",			current,			items: [				{ _tag: "Link", label: "Home", href: "/" },				{ _tag: "Group", value: "reports", label: "Reports", links: [{ label: "Revenue", href: "/reports/revenue", description: "MRR and churn" }] },			],		},	})

Examples

Docs tabs

Links without descriptions make a short list. columns: 2 splits a long one.

API reference

Props

NavigationMenu props
NameTypeDescription
labelrequiredstringThe landmark's name: "Main", "Docs"
itemsrequiredNavigationMenuItem[]—
currentstringThe href of the page showing

Keyboard and accessibility

KeysDoes
Right arrow Left arrowMove along the bar
Down arrow EnterOpen a link's panel
TabWalk into the open panel, then on past it
EscapeClose the panel and go back to its link

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/navigation-menu

Source