Sub nav

A sub nav is a secondary navigation element, typically positioned beneath a primary navigation.

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

Examples

Default

Loading

Subheading

Loading

Localized menu controls

Internal SubNav labels such as the “More” link are rendered in en by default. Use menuLabels to customize these to different locales.

Loading

Optional CTA

Loading

Optional submenu

Submenus appear as a dropdown by default.

Loading

Optional anchor-based submenu

Ensure that the text of each SubNav.Link within the anchor-based submenu fits entirely within a 320px-wide viewport. Failure to do this violates WCAG 1.4.10 Reflow.

Loading

Component props

nametypedefaultrequireddescription
fullWidthbooleanfalsefalseAllows the SubNav to be used at full width, removing default internal padding
menuLabelsPartial<SubNavMenuLabels>English labelsfalseCustomizes the menu’s accessible labels

SubNavMenuLabels is exported from @primer/react-brand.

FieldTypeEnglish defaultPurpose
menuLabelstringNavigation menuAccessible label while the narrow menu is closed
closeLabelstringClose navigation menuAccessible label while the narrow menu is open
activeLabelstringNavigation menu. Current page:Complete prefix while the narrow menu is closed and a current page is present
closeActiveLabelstringClose navigation menu. Current page:Complete prefix while the narrow menu is open and a current page is present
overflowMenuLabelstringMoreVisible and accessible label for the desktop overflow menu

SubNav.Heading is a styled a tag which describes the overarching category of the other links within the SubNav. The SubNav.Heading is structurally identical to a SubNav.Link and differs only in visual styling.

nametypedefaultrequireddescription
hrefstringURL of the page the link goes to
nametypedefaultrequireddescription
hrefstringURL of the page the link goes to
nametypedefaultrequireddescription
aria-currentstringtrueRequired for indicating the current active link
hrefstringtrueURL of the page the link goes to
variant'default'
'muted'
mutedfalseAlternative idle text appearance
nametypedefaultrequireddescription
hrefstringfalseURL of the page the action goes to
nametypedefaultrequireddescription
childrenSubNav.LinkfalseContainer for submenu links
variant'dropdown'
'anchor'
'default'falseAlternative presentation for submenus
aria-labelstring'Sub navigation' (content)falseComplete accessible name for the submenu toggle and content; names the navigation landmark for the anchor variant