Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

header

Introductory content for its nearest sectioning ancestor. Contains headings, logos, navigation, search forms, or other introductory elements.

Usage

Use the <header> element for:

  • Site header with logo, navigation, and search
  • Page header with title and breadcrumbs
  • Article header with title, author, and publication date
  • Section headers with title and description
  • Card headers with title and actions

A page can have multiple header elements: one for the site and additional ones within articles, sections, or other content.

Examples

Default

Basic header without additional styling.

.site

Full-width site header with flexbox layout.

.page

Page header with bottom border and spacing.

.card

Card header with bottom border.

Sticky

Add data-sticky to pin the header to the top of the viewport during scroll. See the data-sticky attribute page for full details and recipes.

Put the sticky header directly in <body>. Sticky positioning only holds inside the header's parent, and a body-level header is also what gets anchor protection: html:has(> body > header[data-sticky]) sets scroll-padding-block-start so in-page links land below the header instead of under it. The padding uses --sticky-offset (measured by the coordinated <html data-sticky> system), falling back to --header-sticky-size, which defaults to the .site header's reserved height. Set --header-sticky-size on :root if your header is taller.

Auto-hiding (data-scroll-hide)

Add data-scroll-hide to make the header sticky, slide it away as the reader scrolls down, and bring it back once they scroll up about 40px. The upward distance adds up across small scroll steps, so slow trackpad or keyboard scrolling reveals it too. A small script loads automatically when the attribute is present. It sets data-hidden while the header is away.

If focus moves into a hidden header, for example when tabbing back to the navigation, the header slides back in, so a focused link is never offscreen. With prefers-reduced-motion: reduce the header still hides and returns, but without the slide.

.transparent

Positions the header absolutely over the top of the page with no background, for headers that sit on a hero image or colour band. Give the hero enough top padding to clear the header, and check the header text still has enough contrast against whatever is behind it.

.centered

Centered header for landing pages.

.compact

Compact header with reduced padding and smaller text.

Variants

Class Description
.site Flexbox layout with space-between, padding, and bottom border
.page Bottom border and margin for page title headers
.card Padding with bottom border for card headers
data-sticky Pins header to top of viewport on scroll (see attribute page)
data-scroll-hide Sticky header that hides on scroll down and returns on scroll up or when it receives focus (sets data-hidden while hidden)
.transparent Absolute positioning with transparent background for hero overlays
.centered Centered text and auto margins for children
.compact Reduced padding and smaller font size

Accessibility

  • A <header> is exposed as the banner landmark only when it is scoped to <body> — that is, it has no <article>, <aside>, <main>, <nav> or <section> ancestor. Non-sectioning wrappers, including VB layout custom elements such as <layout-stack> at body level, don't change this. A header inside one of those elements is a plain section header with no landmark role.
  • Keep one body-level header per page so there is a single banner landmark. The sticky system (<html data-sticky>) uses the same rule to pick which header to pin, so an article or card header is never made sticky.
  • Include skip links at the start of the header to bypass navigation
  • Use <nav> with aria-label to identify navigation regions
  • Sticky headers must not cover focused or linked content. A body-level sticky header gets matching scroll padding automatically. An auto-hiding header slides back when anything inside it receives focus.
  • Ensure transparent headers maintain sufficient contrast with background
  • Consider prefers-reduced-motion for sticky header animations

Related

  • <nav> - Primary navigation typically lives in site headers
  • Navbar patterns - Complete site-header recipes: simple, dropdown, sticky, with search and mobile
  • <hgroup> - For grouping heading with subtitle in headers
  • <footer> - Complementary element for closing content
  • <article> - Header provides article metadata
  • <section> - Header introduces section content
↑