Header
The sticky glass bar at the top of every page: the wordmark, the main links and any actions. On phones the links fold into a menu that opens the side nav as a drawer.
- CSS
css/components/header.css- JS
js/components/sheet.js, js/components/side-nav.js (phone menu)
01 — Options
A. Links
The default, and what this site uses. Up to five links, with the current page underlined. Below 48rem the links fold into the menu button.
B. Links and an action
For apps with one main action. The button stays visible on phones beside the menu button.
C. Search
For sites people search more than browse. The search takes the spare width; on phones it hides, so put one in the drawer or at the top of the page.
D. Menu only
.nav--drawer shows the menu button at every width and never the links. For apps with many sections, where a side nav does the work.
02 — In a page
Markup
Put the header first inside .page, after the background and the cap. The menu button opens the side nav drawer: see Side nav.
03 — Usage
Use it for
- One header per page, the same on every page.
- Short link labels, one word where possible.
.nav--keepinstead of a menu button when there are only two or three links: they wrap on phones.
Avoid
- More than five links. Move the rest into a side nav.
- A theme toggle. Jewel is dark only.
- Hiding links on phones with no menu button.
04 — Accessibility
Notes
- The nav is a landmark labeled “Primary”. Mark the current page with
aria-current="page". - The menu button keeps
aria-expandedin step with the drawer. - Add a skip link before the header so keyboard users can jump to the content, as this site does.