Components
← All components

Scrollspy

stimeo--scrollspy

IntersectionObserver-driven scroll tracker matching active section states to Table of Contents anchors.

The stimeo--scrollspy controller synchronizes Table of Contents (TOC) links to scroll viewport sections. By harnessing the native IntersectionObserver API, it avoids heavy scroll event handlers entirely, ensuring 60 FPS scrolling rendering performance. Features a robust nearest-top calculation algorithm prioritizing the section closest to the trigger margin line, and manages the aria-current=\"location\" state on links gracefully.

running

1. Introduction

This is the introduction section. Scroll down to observe the TOC active highlights tracking your viewport progress dynamically.

2. Basic Usage

Setting up a scrollspy only requires data-controller="stimeo--scrollspy" on the nav and data-stimeo--scrollspy-target="link" on each anchor element.

3. API Reference

Use the offset-value and root-margin-value parameters to precisely align the trigger zone to match your dynamic sticky headers or padding grids.

Keyboard

KeyAction
Scroll As the user scrolls, the link targeting the active section is automatically decorated with aria-current="location" and dispatches stimeo--scrollspy:change.