Sticky Header
A navigation bar that remains anchored to the top of the viewport during scrolling so key links, search, and actions stay reachable
Table of Contents
Structure Diagram
What is Sticky Header?
A navigation bar that remains anchored to the top of the viewport during scrolling so key links, search, and actions stay reachable. It is a core concept in Layout & Responsive within UI / UX.
Core Principles
A Sticky Header uses position: sticky; top: 0 so the navigation bar participates in normal document flow until scrolling reaches the top edge, where it anchors to the viewport. Unlike position: fixed, it reserves its own layout space automatically without requiring manual top padding on the page body.
Once scrolled past the top, adding a subtle bottom border, elevation shadow, or backdrop-filter: blur() separates the header cleanly from scrolling content underneath.
Practical Takeaways
- Keep vertical footprint slim (56–64px): Oversized sticky bars steal valuable reading space, especially on mobile. Consider shrinking on scroll or using a headroom pattern that hides on scroll-down and reveals immediately on scroll-up.
- Prevent anchor occlusion with
scroll-margin-top: Applyscroll-margin-top(matching header height + gap) to anchored headings so hash navigation never lands hidden behind the bar. - Watch out for ancestor
overflow: hidden: Sticky positioning breaks if any ancestor usesoverflow: hidden,auto, orscroll. Preferoverflow: clipwhen horizontal clipping is needed.
Notable Examples
- Documentation shells: Pinning global search (
⌘K), breadcrumbs, and theme controls across long technical guides. - E-commerce sticky buy bars: Showing a compact product price and primary checkout CTA once the hero purchase button scrolls out of view.
- Sticky table headers: Keeping
theadcolumn labels anchored while scanning dense analytics spreadsheets.