Components
← All components

Scrollspy

stimeo--scrollspy

Moves the current mark in a table of contents as you read, without running on every scroll.

  • Core

Keeps a table of contents pointing at the section you are reading. The detection is left to the browser, so no code runs on every scroll event. The current section is the one whose top sits closest to the trigger line, which you can push down by the height of a fixed header. While no section is inside the band, the nearest one stays marked, so the mark never disappears and leaves you lost. The current section is announced as well, and a mark you placed yourself is left alone.

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 offset-value and root-margin-value to move the trigger line in pixel steps, for example to place it just below a sticky header.

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.