NavList

Use NavList to render vertical navigation with optional expandable groups.

Ready to use
import {NavList} from '@primer/react-brand'

Examples

Default

Loading

Groups

Use NavList.Group to organize related navigation items into labelled groups.

Loading

Nested disclosure

Add NavList.SubNav to a NavList.Item when an item needs to expand and collapse nested navigation links.

Loading

Up to five navigation levels

NavList can include up to five levels when a page hierarchy requires it. Use the fewest levels needed; levels one through four can optionally expand or collapse, and level five is reserved for leaf article links.

Loading

With visuals

Use leadingVisual and trailingVisual to add icons to the label area. Visuals are additive: they do not replace disclosure triangles, change item sizing, or move the active and inactive row alignment.

Loading

Accessibility

Give each NavList a clear aria-label, especially when the page includes more than one navigation landmark.

Use aria-current="page" on the link for the current page. Only apply aria-current to leaf items that navigate somewhere, not to disclosure rows with nested items.

Keep group titles and disclosure labels short and descriptive. Items with NavList.SubNav must include visible label text so people can understand what will expand.

Component props

nametypedefaultrequireddescription
childrenReactNodetrueNavList.Item and NavList.Group nodes
aria-labelstringtrueAccessible label for the navigation landmark
aria-labelledbystringfalseID of the element that labels the navigation landmark
classNamestringfalseSets a custom class on the nav element

Forwards all standard HTML attributes for <nav> elements.

nametypedefaultrequireddescription
as'a' | 'button''a'falseElement used for leaf items
childrenReactNodetrueItem label and optional NavList.SubNav for nested disclosure
hrefstringfalseURL for leaf items when rendering as an anchor
aria-current'page', 'step', 'location', 'date', 'time', 'true', 'false'falseMarks a leaf item as current
defaultExpandedbooleanfalsefalseOpens nested NavList.SubNav by default
expandedbooleanfalseControls the nested NavList.SubNav expanded state
onExpandedChange(expanded) => voidfalseCalled when the nested NavList.SubNav expanded state changes
leadingVisualReactElement | IconfalseVisual rendered before the label
trailingVisualReactElement | IconfalseVisual rendered after the label
disabledbooleanfalsefalseDisables the item. Leaf links receive aria-disabled; disclosure buttons receive disabled

Forwards props to the rendered leaf link or disclosure button.

nametypedefaultrequireddescription
titleReactNodefalseHeading text for the group
childrenReactNodetrueNavList.Item nodes
classNamestringfalseSets a custom class on the group list item
nametypedefaultrequireddescription
childrenReactNodetrueNested NavList.Item nodes
classNamestringfalseSets a custom class on the nested ul