Hooks
Functions
useScrollTop
This hook tracks the window scroll position and returns a boolean value indicating whether the user has scrolled past the top of the page.
Example
'use client'
import useScrollTop from '@/utils/hooks/useScrollTop';
const Example = () => {
const { isSticky } = useScrollTop();
return (
<header className={isSticky ? 'sticky' : ''}>
<h1>My Sticky Header</h1>
</header>
);
};
export default Example
| return | Description | Type | Default |
|---|---|---|---|
| isSticky | Indicates whether the page has been scrolled from the top (i.e., if the element should be sticky). | boolean |