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.
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
| Viewport | Layout |
|---|---|
| > 760 wide | Brand, area links, spacer, slot and the tools inline. 56 tall (size.siteHeader) below the top safe area. |
| ≤ 760 wide or ≤ 500 tall | Brand, spacer and slot hidden; the area links fill the bar and scroll sideways; tools behind the menu toggle. |
| ≤ 500 tall | 52 tall (size.siteHeaderShort). |
Tokens
From tokens/components.tokens.json. Override one instance by setting the property without the ct- prefix.
| Custom property | Value | Alias | Resolves to |
|---|---|---|---|
--ct-site-header-background | var(--paper) | {colors.paper} | #FFFFFF #0F141C |
--ct-site-header-border | var(--line) | {colors.line} | #DADDE3 #263041 |
--ct-site-header-brand-color | var(--ink) | {colors.ink} | #101A2E #EEF1F6 |
--ct-site-header-brand-font-size | var(--fs-title) | {type.title} | 20 |
--ct-site-header-brand-font-weight | var(--weight-bold) | {weight.bold} | 700 |
--ct-site-header-brand-gap | var(--space-10) | {space.s10} | 10 pt |
--ct-site-header-brand-tracking | .01em | ||
--ct-site-header-gap-compact | var(--space-12) | {space.s12} | 12 pt |
--ct-site-header-gap | var(--space-16) | {space.s16} | 16 pt |
--ct-site-header-height | var(--size-site-header) | {size.siteHeader} | 56 pt |
--ct-site-header-height-short | var(--size-site-header-short) | {size.siteHeaderShort} | 52 pt |
--ct-site-header-link-color-current | var(--ink) | {colors.ink} | #101A2E #EEF1F6 |
--ct-site-header-link-color | var(--muted) | {colors.muted} | #5B6472 #B0BACA |
--ct-site-header-link-color-hover | var(--ink) | {colors.ink} | #101A2E #EEF1F6 |
--ct-site-header-link-font-size | var(--fs-body) | {type.body} | 16 |
--ct-site-header-link-font-weight-current | var(--weight-medium) | {weight.medium} | 500 |
--ct-site-header-link-font-weight | var(--weight-medium) | {weight.medium} | 500 |
--ct-site-header-link-height | var(--size-minimum-tap-target) | {size.minimumTapTarget} | 44 pt |
--ct-site-header-link-padding-x-compact | var(--space-4) | {space.s4} | 4 pt |
--ct-site-header-link-underline | 2px | ||
--ct-site-header-link-underline-offset | var(--space-6) | {space.s6} | 6 pt |
--ct-site-header-mark-keyline | var(--line) | {colors.line} | #DADDE3 #263041 |
--ct-site-header-mark-size | var(--size-site-mark) | {size.siteMark} | 30 pt |
--ct-site-header-nav-gap-compact | var(--space-4) | {space.s4} | 4 pt |
--ct-site-header-nav-gap | var(--space-20) | {space.s20} | 20 pt |
--ct-site-header-padding-x | var(--gutter) | {spacing.gutter} | 20 pt |
--ct-site-header-padding-x-end-compact | var(--space-8) | {space.s8} | 8 pt |
--ct-site-header-padding-x-start-compact | var(--space-12) | {space.s12} | 12 pt |
--ct-site-header-slot-color | var(--muted) | {colors.muted} | #5B6472 #B0BACA |
--ct-site-header-slot-font-size | var(--fs-sub) | {type.sub} | 13 |
--ct-site-header-slot-gap | var(--space-12) | {space.s12} | 12 pt |
--ct-site-header-tools-panel-gap | var(--space-6) | {space.s6} | 6 pt |
--ct-site-header-tools-segment-padding-x | var(--space-14) | {space.s14} | 14 pt |
--ct-site-header-z-index | var(--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.
Loading the contract…