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
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.
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.---
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>import { ButtonLink, SiteHeader, Stack, ThemeToggle, Typography } from '@santi020k/lumen-react'
// Below 40rem the default header opens its links below the brand; collapse="sheet" opens them in a sheet.
export const Example = () => (
<Stack gap="related">
<SiteHeader
actions={
<>
<ThemeToggle />
<ButtonLink href="/start">Get started</ButtonLink>
</>
}
brand={<a href="/">Acme</a>}
navLabel="Example site"
sticky={false}
>
<a aria-current="page" href="/docs">Docs</a>
<a href="/components">Components</a>
<a href="/pricing">Pricing</a>
</SiteHeader>
<SiteHeader
actions={<ButtonLink href="/start">Get started</ButtonLink>}
brand={<a href="/">Acme</a>}
collapse="sheet"
navLabel="Sheet example site"
sticky={false}
>
<a href="/docs">Docs</a>
<a href="/components">Components</a>
<a href="/pricing">Pricing</a>
</SiteHeader>
<Typography>
<p>Below 40rem, the first header opens its links below the brand. The second opens them in a sheet.</p>
</Typography>
</Stack>
)<script type="module">
import { defineLumenElements } from '@santi020k/lumen-elements/define'
defineLumenElements()
</script>
<!-- Below 40rem the default header opens its links below the brand; collapse="sheet" opens them in a sheet. -->
<lumen-site-header nav-label="Example site" sticky="false">
<div data-slot="site-header-brand"><a href="/">Acme</a></div>
<a aria-current="page" href="/docs">Docs</a>
<a href="/components">Components</a>
<a href="/pricing">Pricing</a>
<div data-slot="site-header-actions">
<lumen-theme-toggle></lumen-theme-toggle>
<lumen-button-link><a href="/start">Get started</a></lumen-button-link>
</div>
</lumen-site-header>
<lumen-site-header collapse="sheet" close-label="Close menu" nav-label="Sheet example site" sticky="false">
<div data-slot="site-header-brand"><a href="/">Acme</a></div>
<a href="/docs">Docs</a>
<a href="/components">Components</a>
<a href="/pricing">Pricing</a>
<div data-slot="site-header-actions">
<lumen-button-link><a href="/start">Get started</a></lumen-button-link>
</div>
</lumen-site-header>use dioxus::prelude::*;
use lumen_dioxus::prelude::*;
#[component]
fn Example() -> Element {
let mut theme = use_signal(|| "light".to_string());
rsx! {
SiteHeader {
brand: rsx! { a { href: "/", "Lumen" } },
actions: rsx! { ThemeToggle { value: theme(), on_value_change: move |next| theme.set(next) } },
a { href: "/docs", "Docs" }
a { href: "/components", "Components" }
}
SiteHeader { collapse: SiteHeaderCollapse::Sheet, nav_label: "Sheet example site", sticky: false,
brand: rsx! { a { href: "/", "Lumen" } },
a { href: "/docs", "Docs" }
a { href: "/components", "Components" }
}
}
}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.
pnpm add @santi020k/lumen-astrolumen add SiteHeaderpnpm add @santi020k/lumen-reactlumen add SiteHeader --target reactpnpm add @santi020k/lumen-elementslumen add SiteHeader --target elementsAPI 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.
| Attribute | Values | Default | Description |
|---|---|---|---|
| brand | Astro slot | ReactNode | data-slot="site-header-brand" | - | Logo lockup, usually a link to the home page. |
| children / default slot | links | - | Primary navigation links, rendered inside a nav landmark. Mark the current page with aria-current="page". |
| actions | Astro 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. |
| navLabel | string | "Main" | Names the primary navigation landmark. Elements use nav-label. |
| menuLabel | string | "Menu" | Names the menu toggle shown on narrow widths. Elements use menu-label. |
| closeLabel | string | "Close menu" | Names the close button at the top of the open sheet. Used with collapse="sheet". Elements use close-label. |
| sticky | boolean | true | Pins 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" | none | banner outside sectioning content | Like 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-width | CSS length | 20rem | Widest the sheet grows; it always leaves 3rem of the page visible beside it. |
| class, className | string | "" | Merges custom classes with the generated ui-* root classes. |
| ...native attributes | HTML 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.
.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.
| Hook | Values | Default | Contract |
|---|---|---|---|
| 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, className | string | "" | 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.
| Key | Action |
|---|---|
| Enter, Space on menu toggle | Open or close the collapsed navigation on narrow widths. A sheet moves focus to its close button. |
| Escape in header | Close the open menu or sheet and return focus to the toggle. |
| Enter, Space on the sheet close button | Close the sheet and return focus to the toggle. |
| Enter on a menu link | Follow the link and close the menu. |
| Tab out of the sheet | Close the sheet once focus leaves it. |