01.25 · Scroll-Based

Scrollspy Navigation

A menu highlights the section you are reading. Best for long docs.

Scroll it

Scroll inside the box or pick a section in the menu, or press Play and it scrolls for you.

Try it

Change a setting, then scroll again or press Play.

Link changes at

How far up a heading must scroll before its link lights.

Off, a link jumps straight to its section.

Copy the prompt

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

Add a scrollspy menu to [your documentation or long page and its section headings]. Keep a menu of section links in place beside the content and highlight the link for the section being read, with a marker that slides to it: a section becomes current once its heading scrolls up past a chosen line, and the last link lights up at the very bottom. Clicking or tapping a link scrolls to its section and lights that link at once, without flickering through the links in between. On phones, turn the menu into a strip across the top. If the visitor has reduced motion turned on, jump to sections instead of gliding. 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

  • Documentation
  • Long articles
  • Settings pages

Avoid on

  • Short pages