01.27 · Scroll-Based

Hide-on-Scroll Header

Scrolling down hides the top bar; scrolling up shows it. Best for mobile pages.

Scroll it

Scroll down inside the box, then back up, or press Show me.

Field Notes · Design

A bar that steps aside while you read

Scroll down and the bar above slides out of the way. Scroll back up to bring it home.

Scroll down

Reading down the page, you do not need the menu, so the bar slides up out of view and the story gets the whole screen.

Scroll back up

The bar returns: at the first move up, or only once you are back near the top, whichever the page asks for.

Near the top it stays

Close to the top of the page the bar always shows, whichever way you scroll.

Small moves do not count

A few pixels of jitter never flip the bar in and out, so it does not flicker.

It floats over the page

The bar sits on top of the page and moves with a transform, so nothing below it jumps.

The end of the page. Scroll back up.

Try it

Change a setting, then scroll again or press Show me.

Speed

How quickly the bar slides away and back.

Comes back

Any scroll up keeps the menu one small move away.

A slim bar stays in view instead of leaving.

Copy the prompt

Paste it into an AI assistant such as ChatGPT, Claude or Cursor to build this in your own project.

Add a hide-on-scroll header to [the top bar of your site]. When the visitor scrolls down, slide the bar up out of view, or shrink it to a slim strip if the settings ask for that; when they scroll back up, bring it back as the settings say. Tell the direction by comparing each scroll position with the last one, ignore moves of a few pixels so the bar never flickers, and always show it near the top of the page. Let the bar float over the content, move it only with a transform and read the scroll once per frame. Touch scrolling counts too. If the visitor has reduced motion turned on, fade the bar out and in instead. Match the settings listed below.

Replace the words in brackets with your own element. Your settings are added at the end.

Free and open source. If this helped, a star on GitHub helps other people find it.

Star on GitHub

What it is

The full explanation is in README.md.

Good for

  • Mobile pages
  • News and blogs
  • Long articles
  • Online shops

Avoid on

  • Short pages
  • Bars with key buttons