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…
Sticky page chrome. On <header> or <footer> it pins the element on its own; on <html> it switches on the coordination system, which measures the sticky header into --sticky-offset so sticky sidebars, the TOC and anchor jumps all line up below it.
Overview
data-sticky works at two levels:
Standalone — <header data-sticky> or <footer data-sticky> sticks on its own. No other attribute or script is needed.
Coordinated — <html data-sticky> turns on StickyManager. It marks the banner header sticky, measures its live height into --sticky-offset on :root, and enables the sidebar rules (data-layout-sticky), so every sticky region lines up below the header without a hardcoded offset.
Sidebars (<nav> / <aside>) do not take data-sticky. They opt in with data-layout-sticky, which only works in coordinated mode.
Standalone sticky header and footer
A header or footer with data-sticky is always sticky: position: sticky at the top (header) or bottom (footer), z-index: 100, and an opaque surface background. It stays sticky at every viewport width.
Anchor jumps stay clear of a standalone sticky banner header: scroll-padding-block-start falls back to --header-sticky-size (set it on :root if your header is taller than the default site header). The footer pads its bottom edge for the on-screen keyboard and the device safe area.
Coordinated mode: <html data-sticky>
Header plus a sticky sidebar
1234567891011
<htmllang="en"data-sticky><body><header>...</header><!-- marked data-sticky automatically --><layout-sidebar><navaria-label="Sections"data-layout-sticky><!-- Sticks below the header; scrolls on its own when taller than the viewport --></nav><article>...</article></layout-sidebar></body></html>
What switching it on adds, compared with standalone mode:
Feature
Standalone (header/footer[data-sticky])
Coordinated (html[data-sticky])
Banner header marked sticky
You add data-sticky
Added automatically to the banner header if missing (and removed again when the system is switched off)
Header stacking
z-index: 100
var(--z-sticky-header) (200), above sticky sidebars and the TOC so dropdowns are not clipped
--sticky-offset
Not measured
Live header height in px, kept current by StickyManager
Sidebars (data-layout-sticky)
No effect
Stick at --sticky-offset + --sticky-gap, capped at the remaining viewport height, scroll on their own
Below 48rem
Header stays sticky
Header returns to position: static to save screen space (the offset drops to 0)
The banner header is the first <header> that is not inside an article, aside, main, nav or section (or their ARIA-role equivalents), so a card or article header is never made sticky.
Toggle the system from script with document.documentElement.toggleAttribute('data-sticky'). The <settings-panel> has a Sticky Navigation toggle that does this and remembers the choice.
Where data-layout-sticky applies
In coordinated mode, data-layout-sticky pins these regions:
<nav> / <aside> that are direct children of a <layout-sidebar> or data-layout="sidebar" element.
<nav> / <aside> / <header> that are direct children of a data-page-layout element.
The CSS variables it provides
Variable
Set by
Use for
--sticky-offset
StickyManager (px; 0px until measured, and while the header is not sticky)
Top offset for any other sticky element so it stays below the header.
--sticky-gap
theme / authors (default var(--size-2xs))
Breathing room between the header and sticky sidebars or TOC.
--z-sticky-header
tokens (default 200)
Coordinated header stacking.
--z-sticky
tokens (default 100)
Coordinated footer and other sticky regions.
--header-sticky-size
authors (optional)
Scroll padding for a standalone sticky header, which is not measured.
For a sidebar inside a sidebar or page layout, use data-layout-sticky instead of writing this by hand.
What triggers a re-measure
Header size changes — a ResizeObserver on the banner header (banners appearing, responsive reflow, wrapping nav).
Window resize — passive resize listener.
Fonts loaded — document.fonts.ready (header height often changes once webfonts arrive).
Toggle events — a document-level, capturing toggle listener, so any <details> or popover opening or closing anywhere on the page.
Initial mount — an immediate measure plus a follow-up in the next animation frame.
Accessibility
Sticky chrome covers content. Coordinated mode sets scroll-padding-block-start on :root to --sticky-offset + --sticky-gap, so in-page links and focused elements scrolled into view land below the header (WCAG 2.4.11 Focus Not Obscured). For a standalone header, set --header-sticky-size if it is taller than the default.
Keep sticky headers short. On small screens a tall pinned header can leave little room for content, which is why coordinated mode un-sticks it below 48rem; standalone headers do not, so keep them compact or use coordinated mode.
Sticky sidebars scroll on their own when taller than the viewport, so every link stays reachable by scrolling and by keyboard.
Users can switch the coordinated system off from the <settings-panel> Sticky Navigation toggle.
Print: src/utils/print.css returns sticky headers, footers and table cells to normal flow.
When NOT to use
Inside scrollable subregions — the coordination system measures against the viewport; a sticky element inside an overflowing container sticks to that container instead.
Tables — use the table's own data-sticky (see the note above).
Related
data-page-layout — its header, nav and aside regions take data-layout-sticky.