Components
Header
Transparent at the top, a floating glass pill after you scroll.
Anatomy#
The header is fixed. ha-header__bar holds a brand, an optional navigation, and an actions group. The header behavior toggles is-scrolled on the root after 24px of scroll.
<header class="ha-header" data-ha-header>
<div class="ha-header__bar">
<a class="ha-brand" href="/"><svg width="28" height="28" aria-hidden="true">...</svg><span class="ha-brand__name">Acme</span></a>
<nav class="ha-header__nav" aria-label="Primary">
<a href="/docs" aria-current="page">Docs</a>
<a href="/blog">Blog</a>
</nav>
<div class="ha-header__actions">
<button class="ha-icon-button ha-icon-button--sm ha-theme-toggle" data-ha-theme-toggle aria-label="Switch theme">...</button>
</div>
</div>
</header>The two states#
Top of the page, then scrolled. The boxes below hold a real header that is positioned inside them for the demo.
Behavior#
import { initHeader } from '@originlabsbr/halora/header';
const stop = initHeader({ selector: '.ha-header', threshold: 24, className: 'is-scrolled' });Mobile#
- Under 640px the bar is 64px, the scrolled pill is 56px plus 8px of padding, so the header never exceeds 64px.
- The navigation is hidden below 900px. Provide your own menu or drawer on phones. Do not let links wrap into a second row.
- The brand name truncates with an ellipsis before the actions can overflow.
- The blur radius drops on phones to keep scrolling smooth.
| Class | Purpose |
|---|---|
ha-header | Fixed root. Add is-scrolled for the pill. |
ha-header__bar | The visible bar or pill. |
ha-brand, ha-brand__name | Logo and name link. |
ha-header__nav | Navigation links. aria-current marks the page. |
ha-header__actions | Buttons on the right. |