useScroll

A hook to detect if the page or a specific element has been scrolled.

Installation

Import the component from the passport-ui package.

components/example.tsx
1
import { useScroll } from "passport-ui";

Usage

Basic example showing how to use the component.

components/example.tsx
1
2
3
4
5
const hasScrolled = useScroll(10);
if (hasScrolled) {
// Add a shadow to the header
}

Additional resources

Documentation and examples are available in Storybook.