Skip to main content

ScrollSpy

Utility
Stable

Scroll position tracker that highlights navigation based on which section is in view. Updates browser hash on scroll.

Quick Import
import { ScrollSpy } from "@cohere-ai/waypoint-ui/scroll-spy";

Live Preview

Loading ScrollSpy...

Props

NameTypeDefaultDescription
targetRefReact.RefObject-Container element to spy on
onUpdatefunction-Callback with active section ID
offsetnumber0Offset from top for activation
smoothbooleantrueSmooth scroll on click
dataAttributestring'scrollspy'Data attribute name for anchors
historybooleantrueUpdates browser hash on scroll
defaultValuestring-Default active section

Examples

Scroll Spy

Track active section as user scrolls through content

1
import { ScrollSpy } from '@cohere-ai/waypoint-ui/scroll-spy';
2
 
3
<ScrollSpy
4
targetRef={containerRef}
5
onUpdate={(activeId) => setActiveSection(activeId)}
6
offset={80}
7
/>

Found an Issue?

If you've encountered a bug or have feedback about the ScrollSpy component, please report it to our team. Your feedback helps us improve Waypoint.

Available for all users • Issue will be created in Linear

Was this page helpful?

Your feedback helps us improve our documentation.

Need Help?

Check out the Whitelabeling Playground to explore customization options or visit the Developer Guide for integration help.