Skip to content

Nav

A horizontal row of links with dropdown menus, or a vertical sidebar column with nested, multi-open disclosure sections. It stays a semantically correct navigation landmark in any context: standalone, in a sidebar, or composed by Header into a full top bar.

Import

import { Nav } from "@hyzer-labs/ui"

Demo

An item with children becomes a dropdown. With an href the label stays a navigable link and a separate chevron opens the menu; without one, the whole label is the trigger. Keyboard: Enter/Space toggle, ArrowDown opens and focuses the menu, Escape closes. Header composes this Nav for you: hand it the same items for a full top bar with branding, actions, and a mobile drawer built in.

<Nav
	items={[
		{ label: 'Home', href: '/docs' },
		{ label: 'Components', href: '/components', children: [
			{ label: 'Button', href: '/docs/components/button' }
		] }
	]}
	ariaLabel="Main navigation"
/>

Props

NameTypeDefaultNote
itemsNavItem[]Required. See NavItem below.
orientation'horizontal' | 'vertical''horizontal'horizontal: a row of links with dropdown menus. vertical: a sidebar column with inline, nested, multi-open disclosure sections.
ariaLabelstring'Main navigation'
chevronIconSnippetReplaces the dropdown chevron.
classstringMerged after the hz-nav class.

NavItem

NameTypeDefaultNote
labelstringRequired.
hrefstringOmit (with children present) for a trigger-only dropdown / section parent.
childrenNavChild[]Makes the item a dropdown (horizontal) or a nested disclosure section (vertical). May contain items or { heading } group labels.
externalbooleanAdds the external-link treatment.
ariaCurrent'page' | 'step' | 'true'Set on the active item.
defaultOpenbooleanVertical only: the section starts open, and re-opens when items is rebuilt (e.g. on navigation).

Theme hooks

What this component promises your CSS. The reference theme styles exactly these — from @layer hz-theme, so your unlayered rules win. See Styling Components for the how.

Root class: .hz-nav

Data attributes

HookValuesStyles
data-orientation'horizontal' | 'vertical'Selects the layout mode — a horizontal row with popover dropdown panels, or a sidebar column with inline nested disclosure sections. Default horizontal.
data-state'open' | 'closed'On .hz-nav-panel — the dropdown/disclosure open/closed vocabulary to animate against.

Part classes

HookValuesStyles
.hz-nav-linkschild elementThe link list — a row (horizontal) or a column (vertical).
.hz-nav-dropdownchild elementThe list item wrapping a submenu.
.hz-nav-triggerchild elementThe label-only section toggle (no href).
.hz-nav-chevronchild elementThe separate chevron button when the item is both a link and a toggle.
.hz-nav-panelchild elementThe submenu list — a popover when horizontal, an inline section when vertical.
.hz-nav-headingchild elementA group label inside a panel: static text, no focus stop.

Accessibility

Horizontal dropdowns follow the APG menu-button pattern. The trigger carries aria-haspopup/aria-expanded, the panel is a role=menu with roving arrow-key focus, and Escape closes it and returns focus to the trigger.

Vertical sections are plain disclosure (aria-expanded on each <button>), not menus, with native keyboard traversal.

A heading entry is static, non-focusable text read in sequence before the links it labels.

References: APG Menu Button pattern