domestic-ui GitHub

Site navigation

The main links of a site in a <nav> landmark, with the current page marked.

Where site navigation is used Site navigation is the list of main links in the sidebar, with the current page marked, or a short row of links in the app bar.

Live example

Vertical (sidebar)

<nav aria-label="Sidebar example" data-nav="vertical">
  <ul>
    <li><a href="#vertical-title">Overview</a></li>
    <li>
      <details open>
        <summary>Projects</summary>
        <ul>
          <li><a href="#vertical-title" aria-current="page">Active</a></li>
          <li><a href="#vertical-title">Archived</a></li>
        </ul>
      </details>
    </li>
    <li>
      <details>
        <summary>Settings</summary>
        <ul>
          <li><a href="#vertical-title">Profile</a></li>
          <li><a href="#vertical-title">Billing</a></li>
        </ul>
      </details>
    </li>
  </ul>
</nav>

Horizontal (top bar)

<nav aria-label="Top bar example" data-nav="horizontal">
  <ul>
    <li><a href="#horizontal-title" aria-current="page">Home</a></li>
    <li>
      <details name="top-bar">
        <summary>Products</summary>
        <ul>
          <li><a href="#horizontal-title">Design system</a></li>
          <li><a href="#horizontal-title">Icons</a></li>
        </ul>
      </details>
    </li>
    <li>
      <details name="top-bar">
        <summary>Company</summary>
        <ul>
          <li><a href="#horizontal-title">About</a></li>
          <li><a href="#horizontal-title">Careers</a></li>
        </ul>
      </details>
    </li>
    <li><a href="#horizontal-title">Contact</a></li>
    <li><a href="#horizontal-title" data-button="primary small">Sign up</a></li>
  </ul>
</nav>

Attributes

Attribute or valueWhereEffect
data-nav="vertical | horizontal"<nav> (empty means vertical)
aria-current="page"the current link (native ARIA)
aria-current="true"a top-level horizontal link to the current sectionmarked like "page"
<details> / <summary>inside an <li> for a collapsible group; open to expand it on load, name for one-at-a-time

Elevation

Horizontal dropdowns use --dui-elevation-popover and its surface, like a popover. They open at once: native details has no open transition.

Keyboard

KeyAction
Tabmoves to the next link or group summary / Shift+Tab: previous
Enter / Spaceon a summary, opens or closes the group
Enteron a link, follows it

Accessibility

  • Native <details> in place of the APG disclosure navigation, not an ARIA menu.
  • aria-current="page" is shown with a bar, a tint and bold text (WCAG 1.4.1).
  • Give each <nav> a distinct aria-label when there are several.
  • Groups do not close on Esc. Enter on the summary does.

Specifications

See also

How other systems do it

For comparison only; these are not the standard this system follows.

  • Apple Human Interface Guidelines: No equivalent
  • Material Design 3: No equivalent
  • Vercel Geist: No equivalent

Search