Header
Site header shell with sticky and scrollspy hooks. Compose the inner content as brand + primary navigation + a compact actions group in a single flex justify-between row inside .container so each cell keeps its natural width. When the row also has to host a search field plus multiple actions, switch to a two-row composition, brand / search / actions on top, navbar full-width below, see the Crowded story for the canonical recipe. Mirrors the footer so header and footer share the same composition vocabulary.
Usage
When to use
- Every page in the site needs a consistent header landmark
- The header must host multiple blocks (brand, navigation, utility links, actions, secondary nav)
- Sticky or fixed behavior is required as the page scrolls
When not to use
- Embedded or single-purpose widgets that are not site-wide
- Pages that only need a minimal back link or breadcrumb - consider a simpler pattern
Do
- Place the brand / logo first in the main row
- Put primary navigation next to it and the actions group last
- Reserve a row above for utility links and language pickers
- Hide the top row on mobile and reveal from
md
Don't
- Don't nest the masthead inside the header - the masthead sits above
- Don't place the skip-link target inside the header; it should appear after
API
Props
| Prop | Type | Default | Description |
|---|---|---|---|
classes | array | - | Additional CSS class words merged into the root element. |
attributes | object | - | Additional HTML attributes spread on the root element. |
Classes
| Class | Capability | Default | Description |
|---|---|---|---|
.subtle | Emphasis | - | Lower emphasis; a muted, quieter weight. |
.neutral | Emphasis | Yes | Default emphasis; the standard weight at balanced contrast. |
.accent | Emphasis | - | Higher emphasis; a stronger, louder weight. |
.sm | Size | - | Small. |
.md | Size | Yes | Medium. |
.lg | Size | - | Large. |
.fluid | Layout | Yes | Full-width, no max-width. |
.contained | Layout | - | Constrained to a max-width. |
.sticky | Position | - | Pins the component to a viewport edge while scrolling. |
.flat | Elevation | Yes | No elevation. |
.raised | Elevation | - | Slight elevation. |
Examples
Sticky
Header sticks to the top of the viewport as the page scrolls.
Shadow on scroll
Shadow and shrink applied after scrolling past the offset via scrollspy self mode.
Mobile menu
Mobile menu toggle (hamburger) revealing the primary navigation.
Horizontal
Brand, navigation and actions on one row, the arrangement most sites start from.
Vertical
Brand and search on the first row, navigation on a second, for a site whose menu is too wide to share a line.
Banded
An accent strip and a utility row above the main bar, the arrangement government and institutional sites use.
Mega
Primary navigation whose panels open into multi-column mega menus.
Search led
Search given the widest slot on the main row, for a site whose primary task is finding a document.
Split
Navigation split away from the brand and actions, so the menu sits on its own line beneath them.
Crowded
Brand, search, navigation and two actions on one row, the density test for the horizontal arrangement.
Minimal
Brand and a single action, for a checkout or sign-up flow with nothing to navigate to.
Accessibility
- WCAG 2.2 AA
<header>provides thebannerlandmark- Mobile toggle button exposes
aria-expandedandaria-controlspointing to the navigation it toggles - Skip-link target appears after the header so keyboard users can bypass navigation
- Masthead (if present) sits above the header, not inside it
- Sufficient color contrast for background, text, and link states
Dependencies
- grid - row and column layout
- container - inner content alignment
- scrollspy - sticky shadow/shrink behavior in self mode
- footer - companion site shell composed the same way