SiteHeader
Build an accessible public website header with caller-owned branding, navigation, actions, locale controls, dropdowns, and a responsive mobile menu.
SiteHeader is the public website shell from @puzzle-ui/pieces. It is
separate from DashboardNavigation: it presents public navigation, branding,
and actions rather than an authenticated application workspace.
API maturity: Stable.
Import and basic usage
import { SiteHeader } from "@puzzle-ui/pieces";
import { Button } from "@puzzle-ui/ui";
<SiteHeader
logo={<strong>Willow & Tide</strong>}
items={[
{ id: "stay", label: "Stay", href: "/stay", active: true },
{ id: "contact", label: "Contact", href: "/contact" },
]}
primaryAction={<Button href="/book">Book a stay</Button>}
/>;Navigation and responsive behavior
Items support stable IDs, descriptions, active state, external-link indication,
and one level of children for dropdown navigation. active is supplied by the
caller; the component does not inspect a router or pathname. On smaller
viewports the existing UI Dialog provides a modal mobile menu with focus
management, Escape handling, and predictable close behavior. Links close the
menu after activation.
sticky, transparent, overlay, minimal, and centered are presentation
options that share the same header layout. scrolled is a caller-supplied
state so applications can decide how and when to observe scroll position.
Slots and ownership
logo, primaryAction, secondaryActions, localeSwitcher, and
utilityNavigation are ReactNode slots. Routing, active-route calculation,
authentication, analytics, and destinations remain application-owned. Use
LocaleSwitcher for caller-supplied
language destinations.
Accessibility and theme behavior
The component renders a semantic header and labeled nav, native links,
disclosure elements for desktop submenus, and a modal dialog for mobile
navigation. Provide meaningful link labels and keep the active item accurate.
It consumes Puzzle Theme tokens, wraps long labels, and supports keyboard focus
and reduced-motion behavior from the shared UI overlay.
API
| Prop | Type | Description |
|---|---|---|
logo | ReactNode | Required branding slot. |
items | readonly SiteNavigationItem[] | Public navigation items and optional children. |
primaryAction, secondaryActions, localeSwitcher, utilityNavigation | ReactNode | Caller-owned header slots. |
variant | SiteHeaderVariant | default, transparent, overlay, minimal, or centered. |
sticky, scrolled | boolean | CSS sticky and caller-supplied scrolled state. |
mobileMenuTrigger | ReactNode | Custom trigger content. |
mobileMenuLabel, mobileMenuTitle, closeLabel, navigationLabel | string | Accessible labels. |
Do not use this component for dashboard sidebars; use Dashboard Navigation for that context.