Xzero UI
Pro library

Site header

A sticky website header that turns solid on scroll, with a gliding active link, mega menu panels, and a mobile sheet.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui/site-header
Live · keyboard ready

Use this as a starting point and replace the sample data with your own.

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui/site-header

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { SiteHeader } from "@/components/xzero/blocks/site-header/site-header";

export function MarketingHeader() {
  return (
    <SiteHeader
      variant="simple"
      brand={{ name: "Acme", href: "/", mark: <Logo /> }}
      items={[
        { value: "product", label: "Product", href: "/product" },
        { value: "pricing", label: "Pricing", href: "/pricing" },
        { value: "docs", label: "Docs", href: "/docs" },
      ]}
      current="pricing"
      secondaryAction={{ label: "Sign in", href: "/sign-in" }}
      primaryAction={{ label: "Start free", href: "/sign-up" }}
    />
  );
}

API reference

SiteHeader

A marketing site header in three variants. It turns solid once the page scrolls, and on narrow containers the links move into a sheet.

PropTypeDefaultDescription
variant"simple" | "centered" | "mega""mega"simple puts links beside the brand, centered centers them in a quiet capsule, mega opens panels for items with links.
brand{ name: string; href?: string; mark?: ReactNode }{ name: "Xzero" }Brand at the start of the bar.
itemsSiteHeaderItem[]siteHeaderExampleItemsTop level destinations: { value, label, href?, links?, feature? }. Items with links open a panel in the mega variant.
currentstring–Value of the item that holds the current page (controlled).
defaultCurrentstring–Initial current item when uncontrolled.
onCurrentChange(value: string) => void–Called when a destination inside an item is chosen, with that item's value.
onNavigate(destination: { label: string; href?: string; section?: string }) => void–Called for every destination: items, panel links, the brand, and actions with an href.
secondaryAction{ label: string; href?: string; onClick?: () => void } | null{ label: "Sign in" }A quiet action before the primary one. Pass null to hide it.
primaryAction{ label: string; href?: string; onClick?: () => void } | null{ label: "Get Xzero" }The one primary action. Pass null to hide it.
stickybooleantrueSticks to the top of its scroll container.
scrollContainerRefObject<HTMLElement | null>–The element that scrolls, when it is not the window.
scrollThresholdnumber8Pixels of scroll before the background turns solid.
labelstring–Accessible name of the navigation landmark.
classNamestring–Extra class on the header.

SiteHeaderBlock

Default export: a preview with a variant switcher over a small scrolling page.

PropTypeDefaultDescription
variantSiteHeaderVariant"mega"Initial variant.

Keyboard interactions

KeysAction
ArrowLeft / ArrowRightMove between top level items in the mega variant.
ArrowDownOn an item with links, opens its panel and focuses the first link.
ArrowUp / ArrowDown / Home / EndMove between links inside an open panel.
EscapeCloses the open panel or the mobile sheet and returns focus to its trigger.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Guidance for AI tools

Blocks are complete, self-contained screens with sample data. Replace the sample data and connect the callbacks described above. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components