Magoo Component UI logo Magoo Component UI
← Catalog

Scroll-spy Nav

scroll-spy-nav molecule experimental

A vertical section-tracking side nav whose active link follows the section currently in view.

The width preview needs a screen wider than the chosen width — use a larger device (or a desktop browser) to see the desktop and tablet layouts.

Default
Three

Props

NameTypeReq
items array ✓

Related components

How to use

behavior.js resolves each link's href to a section via getElementById and observes them with an IntersectionObserver (rootMargin 0px 0px -70% 0px), marking the topmost visible section's link active (data-active + aria-current). Clicking a link activates it immediately. If none of the referenced sections exist (an isolated preview), the observer is skipped and the static active item is left as-is. The click listener and observer are cleaned up on teardown.

Use cases

listnavigation WCAG AA SEO 30 dir: both ai-generated