Skip to content

Block 86 of 297

Site Header

Logo, main menu with dropdowns, a button and a skip link. Menus use native disclosure, so they work without JavaScript.

Puck key
SiteHeaderBlock
Export
siteHeaderBlock
React component
<SiteHeader />
Path
components/puck/site-header-block.tsx
Dependencies
None
License
MIT

About this block

When to use it, how to write for it, and what to change in the code.

What it's for

A general-purpose site header with a logo or site name, a horizontal menu whose items can open dropdowns, and one call-to-action button. Dropdowns are native details elements, so they work by keyboard or tap without scripts. Below the large breakpoint, the menu collapses into a "Menu" button that opens a full-width panel with every link.

  • The main header for a parks, library or nonprofit site
  • Sites with four to seven top sections, some with a few sub-pages
  • Any header that needs a single persistent action like Register or Donate
Writing the content
  • Menu links allows 1 to 7 items, each with up to 8 Sub-links. A top link's own Link becomes an "overview" item at the top of its dropdown.
  • Sub-link Descriptions are optional; use them only when a label is unclear.
  • Set Current section to the active path, like /programs, to underline that link and mark it as the current page.
  • Leave Logo alt text blank when the Site name is showing, so screen readers don't hear the name twice.
Accessibility
  • A skip link appears on the first Tab press and jumps to the Skip link target. It only works if your main element has a matching id.
  • Desktop and mobile menus are separate nav landmarks (the second adds "(mobile)" to its name), and the current link has aria-current="page".
  • Every link and toggle has a 44px minimum height and an indigo focus outline (WCAG 2.4.7).
Customizing the code
  • Change the focusRing constant and the indigo- button classes to rebrand.
  • Dropdowns share a name attribute, so in supporting browsers opening one closes the others.

Editor fields

What content editors see in the P1 sidebar when they select this block.

  • Site nametext
  • Logo image URLtext
  • Logo alt texttext
  • Logo linktext
  • Skip link texttext
  • Skip link targettext
  • Navigation nametext
  • Current sectiontext
  • Menu linksarray
  • Button texttext
  • Button linktext
  • Mobile menu labeltext