Skip to content

Header

A site header bar with branding, navigation, actions, and a responsive hamburger and drawer built in. It composes Nav horizontally in the bar and vertically in the drawer, so one item set drives both.

Import

import { Header } from "@hyzer-labs/ui"

Demo

Pass items plus the logo and actions snippets. Header composes a Nav from those same items: horizontal in the bar, vertical in the mobile drawer. There is nothing for you to wrap.

const navItems: NavItem[] = [
	{ label: 'Home', href: '#' },
	{
		label: 'Components',
		href: '#',
		children: [
			{ label: 'Button', href: '#' },
			{ label: 'Card', href: '#' }
		]
	},
	{ label: 'Foundation', href: '#' },
	{ label: 'Media', href: '#' }
];

<Header items={navItems} bordered>
	{#snippet logo()}<Logo />{/snippet}
	{#snippet actions()}<Button size="sm">Sign in</Button>{/snippet}
</Header>

Props

NameTypeDefaultNote
itemsNavItem[]Navigation — rendered horizontally in the bar and vertically in the drawer. See Nav.
logoSnippetLogo region at the start.
actionsSnippetEnd of the bar; repeated inside the drawer.
stickybooleanfalseposition: sticky at the top of the nearest scroll container.
variant'default' | 'transparent''default'
borderedbooleanfalseBottom hairline — composes with any variant.
mobileBreakpoint'sm' | 'md' | 'lg' | 'none''md'Collapse threshold (640/968/1200px), a container query against the header width. none never collapses.
ariaLabelstring'Main navigation'Names the navigation.
menuIconSnippetReplaces the hamburger icon.
chevronIconSnippetForwarded to the Nav.
classstringMerged after the hz-header class.

Theme hooks

What this component promises your CSS. The reference theme styles exactly these — from @layer hz-theme, so your unlayered rules win. See Styling Components for the how.

Root class: .hz-header

Data attributes

HookValuesStyles
data-variant'default' | 'transparent'Bar surface treatment. Default default.
data-borderedpresent when borderedBottom hairline. Composes with any variant.
data-stickypresent when stickySticks the bar to the top.
data-mobile-breakpoint'sm' | 'md' | 'lg' | 'none'Which width collapses the bar into the drawer. none never collapses. Default md.
data-state'open' | 'closed'On .hz-header-drawer — the drawer open/closed vocabulary to animate against.

Part classes

HookValuesStyles
.hz-header-innerchild elementThe flex bar; owns its padding.
.hz-header-logochild elementWrapper for the logo snippet.
.hz-header-actionschild elementWrapper for the actions snippet (in the bar). Below the mobile breakpoint, an auto inline-start margin pins it to the end, next to the hamburger — override margin-inline-start on this class (e.g. via a descendant selector off your own class prop) for centering or any other placement.
.hz-header-togglechild elementThe hamburger button.
.hz-header-drawerchild elementThe mobile drawer.
.hz-header-drawer-actionschild elementThe actions repeated inside the drawer.

Accessibility

The header is a banner landmark. Its bar and drawer each render a Nav landmark with distinct accessible names (ariaLabel and ariaLabel (menu)), so they do not collide.

The hamburger carries aria-expanded and aria-controls. The open drawer traps focus. Escape closes it and returns focus to the toggle.

At narrow widths, the drawer keeps every link reachable.