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
| Parameter | Type |
|---|---|
threshold | number |
Returns
boolean
Example
// Triggers after scrolling 100px
const hasScrolledPastHeader = useIsScrolled(100);
// Triggers on any scroll
const isScrolled = useIsScrolled(0);