Skip to content

Scrollspy

Tracks the user’s scroll position on the page and automatically highlights the corresponding link in the table of contents.

6.8 KB
•
Updated on August 21, 2026

Installation

Bash

Usage

Code
Code

Examples

Horizontal

API Reference

Scrollspy

The main component that wraps the navigation links and manages the scroll spying logic.


Data Attributes

Navigation links within Scrollspy should use these attributes to connect to sections:

The component adds data-active="true" to the link element when its corresponding section is active.

Keep in mind

  • MIT License: Free and open-source for personal and commercial use. Feel free to copy, tweak, and adapt the components to match your exact needs.
  • Credits & Inspiration: Some components on this site are inspired by or recreated from great ideas across the web. I'm not here to take credit; just to learn, experiment, and push interface craft further.
  • Reach out & Claims: If an attribution was missed, or if you have any inquiry or claim, feel free to reach out directly on X to @adrielzimbril. I'll be glad to update or resolve it right away.