useInView
Tracks viewport intersection with IntersectionObserver.
2.5 KB
•Updated on September 3, 2026
Installation
Bash
pnpm dlx shadcn@latest add @spaceui/hooks-animation-use-in-viewUsage
Code
import { useInView } from '@/hooks/use-in-view'
const [ref, inView] = useInView({ threshold: 0.5 })API Reference
Parameters / Props
| Parameter | Type | Default | Description |
|---|---|---|---|
options.threshold | number | 0 | Ratio threshold. |
Return Value
| Return Type | Description |
|---|---|
[RefObject<T>, boolean, IntersectionObserverEntry?] | State tuple. |