Follows the reader
Scroll the page and the marker moves to whichever section is in view. The sections below are real page content, because the runtime observes against the viewport -- a table of contents inside a small scrolling box would have nothing to react to.
Overview
Scroll this page and watch the marker in the list move. The runtime observes these sections against the viewport, so the current link follows whatever you are reading.
Installation
Each link points at one of these ids. Nothing is wired up by hand -- the component only renders the links, and the runtime moves aria-current.
Usage
The active link is marked with aria-current="location", which is what a screen reader announces, and styled through data-active.
API
Clicking a link jumps to its section and marks it immediately, so the control responds even before the scroll settles.
<Scrollspy
items='[
{
"label": "Overview",
"href": "#overview"
},
{
"label": "Installation",
"href": "#installation"
},
{
"label": "Usage",
"href": "#usage"
},
{
"label": "API",
"href": "#api"
}
]'
active="#overview"
label="Scrollspy"
heading="On this page"
/>