Skip to content
Halorav0.1.0

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.

HTML
<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#

JavaScript
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.
ClassPurpose
ha-headerFixed root. Add is-scrolled for the pill.
ha-header__barThe visible bar or pill.
ha-brand, ha-brand__nameLogo and name link.
ha-header__navNavigation links. aria-current marks the page.
ha-header__actionsButtons on the right.

Edit this page on GitHub

Type to search.