Spy Rail
A scroll-spy table of contents with a reading progress bar. The active section is tracked as the reader scrolls, a marker glides and stretches along the rail, and a click scrolls without flicker.
pixikit.com/docs/app-ui/navigation/spy-rail
Customize
Offset16px
Update hash
Show top
Variant
Collapse below140px
Props
13| Name | Type | Default | Description |
|---|---|---|---|
items | SpyItem[] | None | The entries, when you list them yourself. |
source | SpyTarget | None | The element whose headings are collected when `items` is not given. |
levels | number[] | [2, 3] | The heading levels collected from `source`, such as `[2, 3]` for h2 and h3. |
root | SpyTarget | None | The scroll container to watch. Default: the nearest scrollable ancestor of the source, else the page. |
offset | number | 80 | Pixels at the top of the root a sticky header covers. |
active | string | None | The id of the active entry, when you hold the state. |
onActiveChange | (id: string) => void | None | Called with the id of the entry that becomes active. |
title | string | "On this page" | The heading above the list. |
updateHash | boolean | false | Writes the active id to the address with `history.replaceState`. |
showTop | boolean | false | Shows a "Back to top" row once the reader has scrolled. |
variant | "line" | "dots" | "line" | `line` marks the active entry on a rail, `dots` puts a dot on the rail for each. |
collapseBelow | number | None | Width in px under which the list becomes a dropdown showing the current section. |
className | string | None |