InView
An effect component that triggers entrance transitions or animations when it passes into the viewport.
Detection of the element’s visibility in the viewport is performed using the Intersection Observer API.
Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do.
Basic Animation
Use the activeClassName and inactiveClassName props to apply CSS classes when the element is in or out of view.
Render Props
Use the isInView render prop to access the visibility state directly.
If you are using RSC remember to add the use client directive when accesing render props.
Customizing
globals.css
:root {
--ex-in-view-delay: 0;
--ex-in-view-ease: var(--ease-out);
--ex-in-view-duration: 500ms
}API
| Element | Selector |
|---|---|
InView | .ex-in-view |
| Prop | Type | Default |
|---|---|---|
as | ElementType | span |
asChild | boolean | false |
activeClassName | string | |
inactiveClassName | string | |
initialInView | boolean | false |
once | boolean | false |
root | Element | Document | null | |
rootMargin | string | |
threshold | number | number[] |
Last updated on