Skip to main content
239

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Themes
Web docs
Navigation

SiteHeader

Builds a public website header whose navigation collapses behind a menu, inline or as a sheet, on narrow widths.

Frameworks
Astro · React · Elements · Dioxus
Registry
lumen add SiteHeader
Interaction
Enhanced runtime
01

See it and copy it

Framework example

Choose Astro, React, Elements, or Dioxus to compare native usage against the shared visual output. Each example assumes the framework-level setup is already complete.

AstroCode target · live preview uses Astro
View SiteHeader code

Framework usage

Switch targets to compare the adapter code. This live preview runs the Astro example. Before copying an example, complete the matching framework setup; React, Elements, and Dioxus use their own behavior APIs.Width controls resize the preview container. Resize your browser to test viewport breakpoints.
astro
---
import { ButtonLink, SiteHeader, Stack, ThemeToggle, Typography } from '@santi020k/lumen-astro'
---

<Stack gap="related">
  <SiteHeader sticky={false} navLabel="Example site" style="border: 1px solid hsl(var(--line)); border-radius: var(--ui-radius-lg);">
    <a slot="brand" href="/docs">Acme</a>
    <a href="/docs" aria-current="page">Docs</a>
    <a href="/docs">Components</a>
    <a href="/docs">Pricing</a>
    <ThemeToggle slot="actions" />
    <ButtonLink slot="actions" href="/docs">Get started</ButtonLink>
  </SiteHeader>
  <SiteHeader collapse="sheet" sticky={false} navLabel="Sheet example site" style="border: 1px solid hsl(var(--line)); border-radius: var(--ui-radius-lg);">
    <a slot="brand" href="/docs">Acme</a>
    <a href="/docs">Docs</a>
    <a href="/docs">Components</a>
    <a href="/docs">Pricing</a>
    <ButtonLink slot="actions" href="/docs">Get started</ButtonLink>
  </SiteHeader>
  <Typography>
    <p>Below 40rem, the first header opens its links below the brand. The second, with collapse="sheet", opens them in a sheet from the edge of the screen.</p>
  </Typography>
</Stack>
Edit SiteHeader in browser
02

Choose your target

Add this component

Choose the package for your runtime. All adapters share the Lumen stylesheet. Use the matching registry command when you want a local wrapper for that framework.

bash@santi020k/lumen-astro
pnpm add @santi020k/lumen-astro
bashAstro wrapper
lumen add SiteHeader

API reference

Lumen-specific props and runtime attributes for the Astro primitive. Use the framework differences above and the copyable examples for React composition and Elements attributes; the public adapter types define their supported contracts.

AttributeValuesDefaultDescription
brandAstro slot | ReactNode | data-slot="site-header-brand"-Logo lockup, usually a link to the home page.
children / default slotlinks-Primary navigation links, rendered inside a nav landmark. Mark the current page with aria-current="page".
actionsAstro slot | ReactNode | data-slot="site-header-actions"-Theme toggle, repository link, or call to action. Collapses with the navigation.
collapse"panel" | "sheet""panel"How the navigation and actions collapse below 40rem. panel opens them inline below the brand; sheet opens them in an off-canvas native popover from the inline-end edge, which the toggle opens even before script loads. Without popover support a sheet header keeps its navigation inline.
navLabelstring"Main"Names the primary navigation landmark. Elements use nav-label.
menuLabelstring"Menu"Names the menu toggle shown on narrow widths. Elements use menu-label.
closeLabelstring"Close menu"Names the close button at the top of the open sheet. Used with collapse="sheet". Elements use close-label.
stickybooleantruePins the header to the top of the viewport. Once the page scrolls past 8px every header gets data-scrolled, which adds a border; a sticky header also shrinks.
role (Elements)"banner" | nonebanner outside sectioning contentLike a native header, lumen-site-header is a banner landmark only when it is not inside article, aside, main, nav, or section. An authored role wins.
data-state"open" | "closed"-Set by the script on the root to reflect the collapsed menu or sheet. Without script a panel header keeps the toggle hidden and wraps the navigation below the brand, and a sheet header still opens from its toggle.
--ui-site-header-sheet-widthCSS length20remWidest the sheet grows; it always leaves 3rem of the page visible beside it.
class, classNamestring""Merges custom classes with the generated ui-* root classes.
...native attributesHTML attributes-Forwards standard attributes to the root element unless the component consumes them.

Customize SiteHeader

Start with semantic theme tokens and a class on the public component. Keep its accessible name, focus treatment, and interaction state intact.

cssScoped theme overrides
.product-site-header {
  --surface: 0 0% 100%;
  --ink: 220 20% 15%;
  --line: 220 15% 82%;
}

Apply product-site-header through Astro's class, React's className, or the custom element's class. Verify foreground and background contrast in both schemes.

HookValuesDefaultContract
data-state"open" | "closed"-Set by the script on the root to reflect the collapsed menu or sheet. Without script a panel header keeps the toggle hidden and wraps the navigation below the brand, and a sheet header still opens from its toggle.
class, classNamestring""Merges custom classes with the generated ui-* root classes.

Use the documented hooks above and adapter types when targeting component states. Theme guide · Accessibility verification scope

Keyboard interactions

Keyboard behavior provided by the Astro UIPrimitives runtime for this component.

KeyAction
Enter, Space on menu toggleOpen or close the collapsed navigation on narrow widths. A sheet moves focus to its close button.
Escape in headerClose the open menu or sheet and return focus to the toggle.
Enter, Space on the sheet close buttonClose the sheet and return focus to the toggle.
Enter on a menu linkFollow the link and close the menu.
Tab out of the sheetClose the sheet once focus leaves it.

Web docsFull catalog