demo · v133
Sticky shrink header — the explainer's marquee example
A header that gets compact, dark, and reveals its Subscribe button the moment it sticks. Old solution: IntersectionObserver on a sentinel. New solution: @container scroll-state(stuck: top) — pure CSS.
scroll-state container queries are not supported in this browser. The header will stay big regardless. Needs Chrome 133+.
scroll down to see the header stick & shrink
Heron & Co.
the CSS
.scroller {
overflow-y: auto;
container-type: scroll-state;
container-name: feed;
}
.sticky-header { position: sticky; top: 0; padding: 1rem; }
@container feed scroll-state(stuck: top) {
.sticky-header { padding: 0.5rem 1rem; background: #000; color: #fff; }
}
The other two scroll-state queries — scrolled and snapped — cover the rest of the "style based on scroll position" family. Each replaces a real scroll/IntersectionObserver pattern that web apps have shipped for a decade.