Skip to content

Site header ​

When to use it ​

Use this opt-in header for a logo, primary navigation and language or account popovers. The whole header slides away when scrolling down and returns when scrolling up. Opening a menu or popover keeps the full navigation available.

Compatibility ​

Existing .logo, .c-menu, .nav-extra and .c-menu-toggle markup is supported separately by the Tickster theme and main.js. Updating framework assets does not require migrating those applications. Download can keep its existing HTML.

The new behavior only initializes on .c-site-header. Its styles and state classes are scoped to that component. Applications can adopt this markup independently when they want the new header; future framework upgrades do not require copying the portal HTML again.

Variants ​

The base header is sticky and keeps its own space in the document flow. Add .c-site-header--floating for inset positioning, rounded corners, gradient border, shadow and optional backdrop blur on screens at least 1200px wide. Below 992px, both variants use a 60px row with the menu toggle on the left, the logo centered in the header and language or account actions on the right. Icon labels remain available to screen readers.

What it looks like ​

Use View fullscreen to see the floating variant on a wide screen. Scroll inside the preview to see the whole header slide away.

How to use it ​

Place a Skip link before the header as the first focusable element: <a href="#main" class="c-skip-link">Skip to content</a>. It is independent of the header and remains available when the header slides away.

The header handles its own positioning and scroll visibility with .is-hidden. No component class or header offset is needed on main or other page content. The sticky header reserves its own space; from 1200px, .c-site-header--floating uses fixed positioning and overlays the page. Keep .t-dark on the header so its buttons and popovers use dark tokens regardless of the page theme.

Wrap the visible row in .c-site-header__surface. Place the toggle first, followed by the logo, primary navigation and actions so keyboard focus follows the compact layout. It owns the background, blur, border and shadow, so the logo, navigation and optional actions do not need individual backgrounds. The surface also works with other content or without a navigation menu. Keep popover containers as direct children of the header, outside the surface, so fallback popovers remain positioned against the viewport.

Use unique IDs for each menu and popover. Connect the menu toggle with aria-controls and real popover buttons with popovertarget. Include the framework CSS and JS bundles.

html
<header class="t-dark c-site-header">
    <div class="c-site-header__surface">
        <button type="button" class="c-site-header__toggle"
            aria-controls="primary-menu" aria-expanded="false"
            data-label-open="Menu" data-label-close="Close menu">
            <svg class="c-site-header__toggle-open" viewBox="0 0 48 48" width="26" height="26" aria-hidden="true"><path d="M3 22h42a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1v-2a1 1 0 0 1 1-1zM3 8h42a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V9a1 1 0 0 1 1-1zm0 28h20a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1v-2a1 1 0 0 1 1-1z"/></svg>
            <svg class="c-site-header__toggle-close" viewBox="0 0 48 48" width="26" height="26" aria-hidden="true"><path d="M36.73 8.44 24 21.17 11.27 8.44a1 1 0 0 0-1.41 0L8.44 9.86a1 1 0 0 0 0 1.41L21.17 24 8.44 36.73a1 1 0 0 0 0 1.41l1.42 1.42a1 1 0 0 0 1.41 0L24 26.83l12.73 12.73a1 1 0 0 0 1.41 0l1.42-1.42a1 1 0 0 0 0-1.41L26.83 24l12.73-12.73a1 1 0 0 0 0-1.41l-1.42-1.42a1 1 0 0 0-1.41 0Z"/></svg>
            <span class="c-site-header__toggle-label" data-header-toggle-label>Menu</span>
        </button>
        <a class="c-site-header__logo" href="/" aria-label="Home">…</a>
        <nav id="primary-menu" class="c-site-header__menu" aria-label="Main navigation">…</nav>
        <div class="c-site-header__actions">
            <button type="button" class="c-site-header__popover-toggle"
                popovertarget="language-menu"><svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" stroke-width="2" viewBox="0 0 32 32" width="40" height="24"><g fill="none" stroke="currentColor" stroke-miterlimit="10"><path d="M16 1v30M1 16h30"/><ellipse cx="16" cy="16" stroke-linecap="square" rx="8.571" ry="15"/><path d="M3.31 8h25.38M3.31 24h25.38"/><circle cx="16" cy="16" r="15" stroke-linecap="square"/></g></svg><span class="c-site-header__language-label">Language</span></button>
        </div>
    </div>
    <div id="language-menu" class="c-site-header__popover" popover="auto">…</div>
</header>
html
<header class="t-dark c-site-header c-site-header--floating">
    <!-- Same children as the base header. -->
</header>
html
<header class="t-dark c-site-header c-site-header--floating">
    <div class="c-site-header__surface">
        <a href="/" class="c-site-header__logo" aria-label="Home">…</a>
        <div class="c-site-header__actions">
            <a href="/support" class="c-button c-button--primary">Support</a>
        </div>
    </div>
</header>

Unified menu ​

Add .c-site-header--unified to use one menu button for local and global navigation. Put the local links first in .c-site-header__local and language, country or cross-application choices afterwards in .c-site-header__global. Keep both parts inside the same .c-site-header__menu; links are never copied or moved by JavaScript. Wrap each set of global choices in .c-site-header__global-group. On tablets, these groups form two columns, for example Country beside Language. Smaller screens keep stacked groups. On desktop the panel sizes to its groups (also limited by the viewport). Groups wrap when needed, and group dividers disappear in multi-column layouts. A single group keeps a compact panel.

On medium screens and below, the button sits left of the centered logo and opens one scrollable list with local links first. At larger sizes the local links remain in the header, the button sits at the right and expands the global choices below it. Keep an optional call to action in .c-site-header__actions after the navigation, with .c-site-header__cta on its link. It stays beside the menu button on desktop and to the right of the logo on mobile, using the normal styling of its c-button classes. The grid reserves room for the full button; on narrow screens the logo scales slightly and can shift within the space between the controls.

html
<header class="t-dark c-site-header c-site-header--floating c-site-header--unified">
    <div class="c-site-header__surface">
        <button type="button" class="c-site-header__toggle" aria-controls="unified-demo-menu" aria-expanded="false" data-label-open="Menu" data-label-close="Close menu">
            <svg class="c-site-header__toggle-open" viewBox="0 0 48 48" width="26" height="26" aria-hidden="true"><path d="M2 8h44v4H2zm0 14h44v4H2zm0 14h22v4H2z"/></svg>
            <svg class="c-site-header__toggle-close" viewBox="0 0 48 48" width="26" height="26" aria-hidden="true"><path d="m10 7 14 14L38 7l3 3-14 14 14 14-3 3-14-14-14 14-3-3 14-14L7 10z"/></svg>
            <span class="c-site-header__toggle-label" data-header-toggle-label>Menu</span>
        </button>
        <a href="#" class="c-site-header__logo" aria-label="Tickster">
            <svg width="120" height="50"><use href="/styleguide/ui-framework/symbol/svg/sprite.symbol.svg#logo"/></svg>
        </a>
        <nav id="unified-demo-menu" class="c-site-header__menu" aria-label="Site navigation">
            <div class="c-site-header__local">
                <a href="#" class="is-current" aria-current="page">Events</a>
                <a href="#">MyTickster</a>
                <a href="#">Support</a>
            </div>
            <div class="c-site-header__global">
                <div class="c-site-header__global-group">
                    <h2 class="c-site-header__title">Country</h2>
                    <a href="#" class="is-current" aria-current="true">Sweden</a>
                    <a href="#">Norway</a>
                    <a href="#">Denmark</a>
                </div>
                <div class="c-site-header__global-group">
                    <h2 class="c-site-header__title">Language</h2>
                    <a href="#" class="is-current" aria-current="true">English</a>
                    <a href="#">Svenska</a>
                    <a href="#">Norsk</a>
                    <a href="#">Dansk</a>
                </div>
            </div>
        </nav>
        <div class="c-site-header__actions">
            <a href="#" class="c-button c-button--secondary c-site-header__cta">Boka ett möte</a>
        </div>
    </div>
</header>

Opening the menu keeps the header visible. On desktop, keyboard activation or Arrow Down moves focus directly to the global choices. Compact layouts lock page scrolling and keep Tab navigation inside the header while open. Escape closes it and returns focus to the button; clicking outside or moving keyboard focus outside dismisses the desktop panel. Switching between compact and desktop closes the disclosure and restores scrolling. No Popover API is needed, and all links remain visible when JavaScript is disabled.

The existing header markup and separate popover variant remain supported without this modifier. See the Portal, Support, Download and MyTickster login examples to try the unified version.

First paint ​

Announce JavaScript support early in the document head, before stylesheets. The unified header then starts in its closed layout while the component bundle loads, avoiding a flash of the expanded fallback menu and the resulting content shift. Without JavaScript, the class is never added and all links remain available.

html
<head>
    <script>document.documentElement.classList.add('has-site-header-js');</script>
    <!-- Framework stylesheet and application scripts -->
</head>

Wrap a normal link and its submenu in .c-site-header__item. Add .c-toggle to the parent link for a down/up arrow that follows its aria-expanded state. The arrow is hidden on compact screens, where the child links are always visible. The parent remains a working link: clicking it or pressing Enter follows its URL. On desktop, hovering or focusing the item opens the submenu; leaving closes it after 300ms, matching the About navigation. Escape closes it and restores focus; Arrow Down opens it and focuses the first child. On compact screens the child links stay visible, indented below their parent.

html
<div class="c-site-header__item">
    <a href="/support" class="c-toggle">Support</a>
    <div class="c-site-header__submenu">
        <a href="/download">Download tickets</a>
    </div>
</div>

Add .is-current to the parent when a child is current, and aria-current="page" to the child link. Submenus use ordinary elements and also work without the Popover API. On desktop, they appear with the shared fade-in animation using --duration-short (200ms) and --ease-out. This animation is disabled when the user prefers reduced motion.

Popovers align with their matching button and stay within the viewport. Their arrow points at the button, including after a resize or a change in button width. Native popovers handle outside clicks. The JS fallback provides opening, outside-click dismissal and Escape when the Popover API is unavailable. Escape returns focus to the trigger. Popover content scrolls inside .c-popup__body, leaving its shadow unclipped.

With JavaScript disabled, the primary links remain visible and browsers with Popover API support can still use native popover buttons. The JS fallback requires JavaScript.

The component controls the logo size (120 × 50px), link weight (300) and current-link weight (400); no font utility classes or <strong> wrapper are needed. The surface uses fixed dark background and text colors by default. Colors can be adapted with --site-header-surface and --site-header-color. The floating border can be customized with --site-header-border-gradient. Reduced-motion preferences disable the header transitions.