Skip to content
PixiKit

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
NameTypeDefaultDescription
itemsSpyItem[]NoneThe entries, when you list them yourself.
sourceSpyTargetNoneThe element whose headings are collected when `items` is not given.
levelsnumber[][2, 3]The heading levels collected from `source`, such as `[2, 3]` for h2 and h3.
rootSpyTargetNoneThe scroll container to watch. Default: the nearest scrollable ancestor of the source, else the page.
offsetnumber80Pixels at the top of the root a sticky header covers.
activestringNoneThe id of the active entry, when you hold the state.
onActiveChange(id: string) => voidNoneCalled with the id of the entry that becomes active.
titlestring"On this page"The heading above the list.
updateHashbooleanfalseWrites the active id to the address with `history.replaceState`.
showTopbooleanfalseShows 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.
collapseBelownumberNoneWidth in px under which the list becomes a dropdown showing the current section.
classNamestringNone

Related