In View
Easily animate elements when they come into view. You can apply animations to elements when they enter the viewport, or when they are fully visible.
Examples
Basic in view
Basic in view with margin option
In view with images and margin option
Installation
npx shadcn add "https://ui.ndekocode.dev/c/in-view.json"Component API
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | The content inside the InView component. | |
| variants | { hidden: Variant; visible: Variant; } | { hidden: { opacity: 0 }, visible: { opacity: 1 } } | Variants to define the animation states. |
| transition | Transition | Specifies the animation transitions. | |
| viewOptions | UseInViewOptions | Options to configure the in-view behavior. | |
| as | React.ElementType | 'div' | The HTML element to render the component as. |
| once | Boolean | undefined (false) | If true, the animation will play only once. |