Skip to content
All effects

Auto-hide smart header

A header that hides when you scroll down and comes back the moment you scroll up.

Interactive

This is the real effect. Scroll or move your mouse inside the frame to try it.

The prompt

Add an auto-hide behaviour to the header of this website (a smart header that hides when you scroll down and comes back when you scroll up, also called a headroom header). Behaviour, two separate states: 1. Tint: once the page has scrolled more than about 40px, give the header a background, so the content scrolling underneath does not show through. Remove it again at the top. 2. Direction: when the visitor scrolls down more than a small threshold (about 10px of travel), slide the header up out of view with transform: translateY(-100%). As soon as they scroll up, slide it back in. Never hide it in the first 100px of the page or while the mobile menu is open, and show it again when an element inside it gets keyboard focus. Use a passive scroll listener with requestAnimationFrame and a 300ms ease transition. If there is a WordPress admin bar, offset the header with top: var(--wp-admin--admin-bar--height, 0px). Respect prefers-reduced-motion by removing the slide transition. Style: build it in the existing design system of this website. Reuse its colours, fonts, spacing, corner radius and existing classes or components, and don't add new colours or fonts. Use real content from this website for any text or images in the effect (its headings, services and copy), never placeholder text. If the project has no design system yet, ask me for the brand colours and fonts before you start.

What it is

A header that hides itself. It knows which way you are scrolling. Reading down? It slides away and gives you the full screen. Scrolling back up? It is right there.

When it works

Almost every site with longer pages. It is a small thing, but people notice a header that is always in the way. Especially on mobile, where every pixel counts. The Living with Prompts header works like this.

Get it right

  • Keep the tint and the hiding separate. They react to different things.
  • Use a small threshold, otherwise the header flickers.
  • Bring it back when someone tabs into it with the keyboard.

Also called

  • Hide on scroll header
  • Smart header
  • Headroom header
  • Auto-hiding navbar

More effects.

All effects