Skip to main content

useIsScrolled

useIsScrolled()

function useIsScrolled(threshold): boolean;

Defined in: src/utils/useIsScrolled/useIsScrolled.ts:26

Tracks whether the user has scrolled past a specified threshold.

This hook is useful for showing/hiding navigation elements, implementing scroll-to-top buttons, or triggering animations based on scroll position.

Parameters

ParameterType
thresholdnumber

Returns

boolean

Example

// Triggers after scrolling 100px
const hasScrolledPastHeader = useIsScrolled(100);

// Triggers on any scroll
const isScrolled = useIsScrolled(0);