Skip to main content
PimentCSS v1.0.1, what's new
Home

Navigation

Header nav items, active state, and responsive shell patterns.

Overview

.nav-item is the shared link style for header bars and vertical in-page lists. Wrap horizontal groups in .nav__list; stack sections with .inpage-nav. The .header-nav pattern adds logo, main links, and an optional actions slot (buttons).

PartClassRole
Item.nav-itemNav link (8px padding, 12px gap)
Icon.nav-item__iconOptional 20px icon (often trailing)
Selected.nav-item--selectedActive item (action color)
List.nav__listHorizontal <ul> in header
In-page.inpage-navVertical stack of .nav-item
Header.header-navLogo + nav + actions row

Prerequisites

  • PimentCSS installed, Installation.
  • Icons, optional nav-item__icon via ph() (Phosphor in this doc).
  • Buttons, header actions use Buttons (.btn--transparent, .btn--primary).

Each item is an <a href="…">. Doc-only .nav-item--hover previews hover color; live pages use :hover and :focus-visible. Selected uses aria-current plus .nav-item--selected when you need the spec modifier.

Structure

Horizontal header links belong in <ul class="nav__list"> inside a labeled <nav>. Vertical section links use .inpage-nav without a list (anchors only).

In-page navigation

Simple vertical nav for jumping between sections on the same page. For multi-level side nav with rails, see In-page anchors.

Desktop uses a three-column grid (1fr auto 1fr): logo at the start, links centered, optional actions at the end. Below 48rem viewport width, links and buttons move into a drawer opened with .header-nav__toggle. Use .header-nav--compact only for doc previews or embedded narrow frames.

Logo + 3 links + button

Logo + burger (drawer)

Preview uses .header-nav--compact to show the mobile drawer. Open the menu icon; the panel stacks above the demo with a raised z-index.

Class reference

ClassDescription
.nav-itemNav link: inline flex, body text color, hover primary
.nav-item--hoverDoc-only hover preview
.nav-item--selectedActive item (action text color)
.nav-item__icon20px icon slot (currentColor)
.nav__listHorizontal flex list for header links
.inpage-navVertical column of full-width items
.header-navHeader bar grid (logo | nav | actions)
.header-nav__panelWraps nav + actions (drawer on mobile)
.header-nav__toggleBurger control (visible below 48rem or with --compact)
.header-nav--openDrawer expanded (toggle with JS)
.header-nav--compactForce drawer layout (doc / narrow embed)
.header-nav__logoBrand mark slot (~25×32px)
.header-nav__navMain link list landmark
.header-nav__actionsTrailing buttons (full width in drawer)

Customize (Sass)

  1. Override item padding, list gap, and header spacing before importing components.
    @use "pimentcss-design-system" with (
      $nav-item-padding: 0.5rem,
      $nav-item-gap: 0.75rem,
      $nav-list-gap: 0.5rem,
      $header-nav-gap: 2rem,
      $header-nav-actions-gap: 0.75rem
    );
  2. Run after editing _navigation.scss.
    npm run build:css

Accessibility (RGAA / WCAG)

Navigation landmarks

  • Landmark, wrap primary links in <nav aria-label="Main navigation"> (unique label per nav).
  • Current location, aria-current="page" on the active link; do not rely on color alone.
  • Focus, :focus-visible outline is built in; keep tab order logical (logo, links, actions).
  • Icons, trailing icons are decorative when text is visible; use aria-hidden="true".
  • Logo link, aria-label on the home/logo anchor if there is no visible text.
  • Search, icon-only search needs aria-label="Search" on the button.
  • Mobile menu, sync aria-expanded on .header-nav__toggle; close on Escape and after link selection.
  • Skip link, pages with header nav should still offer skip to main content (see doc layout).

Next steps