Skip to content

Signal

Components

Site header

The sticky site header: brand, area links, a slot and the tools menu; collapses on phones.

The sticky header every page shares: the brand, area links, a page slot and the tools menu. On phones the brand and slot hide, the area links scroll sideways at full-size targets, and the tools (theme switch, GitHub) move behind a Menu toggle.

Live example

The real classes from /site/chitransit.css in frames at phone, tablet and desktop widths, in the docs theme. The contract below shows each width in light and dark.

Phone · 390 × 760
Tablet · 768 × 900
Desktop · 1280 × 800

Code

<header class="ct-site-header">
  <a class="ct-site-brand" href="/"><img class="ct-site-mark" src="/icon-192.png" alt="ChiTransit" width="30" height="30"><span aria-hidden="true">ChiTransit</span></a>
  <nav class="ct-site-nav" aria-label="ChiTransit">
    <a href="/">Home</a><a href="/app/" aria-current="page">Web app</a><a href="/docs/">API docs</a>
  </nav>
  <div class="ct-site-spacer"></div>
  <div class="ct-site-slot"><span>Connected</span></div>
  <div class="ct-menu ct-menu--inline ct-site-tools" data-collapse="(max-width:760px), (max-height:500px)">
    <div class="ct-menu-panel" id="site-tools">
      <div class="ct-segmented" role="group" aria-label="Theme">…</div>
      <a class="ct-menu-item" href="https://github.com/…" aria-label="GitHub repository"><svg aria-hidden="true">…</svg><span class="ct-menu-item-label">GitHub</span></a>
    </div>
    <button type="button" class="ct-menu-toggle" aria-label="Theme and links" aria-expanded="false" aria-controls="site-tools">…</button>
  </div>
</header>
<script src="/vendor/signal/menu.js" defer></script>

Responsive behavior

ViewportLayout
> 760 wideBrand, area links, spacer, slot and the tools inline. 56 tall (size.siteHeader) below the top safe area.
≤ 760 wide or ≤ 500 tallBrand, spacer and slot hidden; the area links fill the bar and scroll sideways; tools behind the menu toggle.
≤ 500 tall52 tall (size.siteHeaderShort).

Tokens

From tokens/components.tokens.json. Override one instance by setting the property without the ct- prefix.

Custom propertyValueAliasResolves to
--ct-site-header-backgroundvar(--paper){colors.paper}#FFFFFF #0F141C
--ct-site-header-bordervar(--line){colors.line}#DADDE3 #263041
--ct-site-header-brand-colorvar(--ink){colors.ink}#101A2E #EEF1F6
--ct-site-header-brand-font-sizevar(--fs-title){type.title}20
--ct-site-header-brand-font-weightvar(--weight-bold){weight.bold}700
--ct-site-header-brand-gapvar(--space-10){space.s10}10 pt
--ct-site-header-brand-tracking.01em
--ct-site-header-gap-compactvar(--space-12){space.s12}12 pt
--ct-site-header-gapvar(--space-16){space.s16}16 pt
--ct-site-header-heightvar(--size-site-header){size.siteHeader}56 pt
--ct-site-header-height-shortvar(--size-site-header-short){size.siteHeaderShort}52 pt
--ct-site-header-link-color-currentvar(--ink){colors.ink}#101A2E #EEF1F6
--ct-site-header-link-colorvar(--muted){colors.muted}#5B6472 #B0BACA
--ct-site-header-link-color-hovervar(--ink){colors.ink}#101A2E #EEF1F6
--ct-site-header-link-font-sizevar(--fs-body){type.body}16
--ct-site-header-link-font-weight-currentvar(--weight-medium){weight.medium}500
--ct-site-header-link-font-weightvar(--weight-medium){weight.medium}500
--ct-site-header-link-heightvar(--size-minimum-tap-target){size.minimumTapTarget}44 pt
--ct-site-header-link-padding-x-compactvar(--space-4){space.s4}4 pt
--ct-site-header-link-underline2px
--ct-site-header-link-underline-offsetvar(--space-6){space.s6}6 pt
--ct-site-header-mark-keylinevar(--line){colors.line}#DADDE3 #263041
--ct-site-header-mark-sizevar(--size-site-mark){size.siteMark}30 pt
--ct-site-header-nav-gap-compactvar(--space-4){space.s4}4 pt
--ct-site-header-nav-gapvar(--space-20){space.s20}20 pt
--ct-site-header-padding-xvar(--gutter){spacing.gutter}20 pt
--ct-site-header-padding-x-end-compactvar(--space-8){space.s8}8 pt
--ct-site-header-padding-x-start-compactvar(--space-12){space.s12}12 pt
--ct-site-header-slot-colorvar(--muted){colors.muted}#5B6472 #B0BACA
--ct-site-header-slot-font-sizevar(--fs-sub){type.sub}13
--ct-site-header-slot-gapvar(--space-12){space.s12}12 pt
--ct-site-header-tools-panel-gapvar(--space-6){space.s6}6 pt
--ct-site-header-tools-segment-padding-xvar(--space-14){space.s14}14 pt
--ct-site-header-z-indexvar(--z-header){zIndex.header}1000 index

Variants

One form; no variants. .ct-site-header holds .ct-site-brand, .ct-site-nav, .ct-site-spacer, .ct-site-slot and .ct-site-tools (a .ct-menu.ct-menu--inline). The phone layout comes from the viewport and the menu's data-collapse. Nothing else exists.

<!-- Do -->
<nav class="ct-site-nav" aria-label="ChiTransit">
  <a href="/">Home</a><a href="/app/" aria-current="page">Web app</a>
</nav>
<!-- Don't: mark the current area by color alone -->
<nav class="ct-site-nav" aria-label="ChiTransit">
  <a href="/">Home</a><a href="/app/" style="color:var(--accent)">Web app</a>
</nav>

Usage

Do

  • Mark the current area with aria-current="page".
  • Use var(--site-header-offset) (the header height plus the top safe area) for sticky offsets below it; the header sets the page's scroll padding itself.
  • Give the tools menu data-collapse="(max-width:760px), (max-height:500px)": the medium and short breakpoints.

Don't

  • Don't put primary navigation in the tools menu.
  • Don't put anything a phone user needs in the slot; it hides on phones.

Accessibility

  • A <header> landmark; the area links are a <nav> with a label.
  • Area links and the menu toggle are at least 44pt tall; on phones the links are at least 44pt wide.
  • The current area differs by weight and underline, not color alone.

Contract

Contract: components/site-header.yaml. States are drawn live by transit.js.