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

<div style={{position: 'relative', height: 100, width: '100%'}}>
  <SubNav>
    <SubNav.Heading href="#">Features</SubNav.Heading>
    <SubNav.Link href="#">Actions</SubNav.Link>
    <SubNav.Link href="#">Packages</SubNav.Link>
    <SubNav.Link href="#" aria-current="page">
      Copilot
    </SubNav.Link>
    <SubNav.Link href="#">Code review</SubNav.Link>
  </SubNav>
</div>

Subheading

<div style={{position: 'relative', height: 100, width: '100%'}}>
  <SubNav>
    <SubNav.Heading href="#">AI</SubNav.Heading>
    <SubNav.SubHeading href="#" aria-current="page">
      Copilot
    </SubNav.SubHeading>
    <SubNav.Link href="#">What&apos;s new</SubNav.Link>
    <SubNav.Link href="#">Plans &amp; pricing</SubNav.Link>
    <SubNav.Link href="#">For business</SubNav.Link>
  </SubNav>
</div>

Shadow

<div style={{position: 'relative', height: 100, width: '100%'}}>
  <SubNav hasShadow>
    <SubNav.Heading href="#">Features</SubNav.Heading>
    <SubNav.Link href="#">Actions</SubNav.Link>
    <SubNav.Link href="#">Packages</SubNav.Link>
    <SubNav.Link href="#" aria-current="page">
      Copilot
    </SubNav.Link>
    <SubNav.Link href="#">Code review</SubNav.Link>
  </SubNav>
</div>

Optional CTA

<div style={{position: 'relative', height: 100, width: '100%'}}>
  <SubNav hasShadow>
    <SubNav.Heading href="#">Features</SubNav.Heading>
    <SubNav.Link href="#">Actions</SubNav.Link>
    <SubNav.Link href="#">Packages</SubNav.Link>
    <SubNav.Link href="#" aria-current="page">
      Copilot
    </SubNav.Link>
    <SubNav.Link href="#">Code review</SubNav.Link>
    <SubNav.Action href="#">CTA</SubNav.Action>
  </SubNav>
</div>

Optional submenu

Submenus appear as a dropdown by default.

<div style={{position: 'relative', height: 300, width: '100%'}}>
  <SubNav hasShadow>
    <SubNav.Heading href="#">Features</SubNav.Heading>
    <SubNav.Link href="#" aria-current="page">
      Actions
      <SubNav.SubMenu>
        <SubNav.Link href="#">Actions feature one</SubNav.Link>
        <SubNav.Link href="#">Actions feature two</SubNav.Link>
        <SubNav.Link href="#">Actions feature three</SubNav.Link>
        <SubNav.Link href="#">Actions feature four</SubNav.Link>
      </SubNav.SubMenu>
    </SubNav.Link>
    <SubNav.Link href="#">Packages</SubNav.Link>
    <SubNav.Link href="#">Copilot</SubNav.Link>
    <SubNav.Link href="#">Code review</SubNav.Link>
  </SubNav>
</div>

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.

<div style={{position: 'relative', height: 300, width: '100%', overflowY: 'scroll'}}>
  <Box style={{height: 1000}}>
    <SubNav>
      <SubNav.Heading href="#">Features</SubNav.Heading>
      <SubNav.Link href="#" aria-current="page">
        Actions
        <SubNav.SubMenu variant="anchor">
          <SubNav.Link href="#">Actions feature one</SubNav.Link>
          <SubNav.Link href="#">Actions feature two</SubNav.Link>
          <SubNav.Link href="#">Actions feature three</SubNav.Link>
          <SubNav.Link href="#">Actions feature four</SubNav.Link>
        </SubNav.SubMenu>
      </SubNav.Link>
      <SubNav.Link href="#">Packages</SubNav.Link>
      <SubNav.Link href="#">Copilot</SubNav.Link>
      <SubNav.Link href="#">Code review</SubNav.Link>
    </SubNav>
  </Box>
</div>

Component props

nametypedefaultrequireddescription
hasShadowbooleanfalsefalseApplies optional shadow, along with a fixed background color
fullWidthbooleanfalsefalseAllows the SubNav to be used at full width, removing default internal padding

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