Fade In
FreeReveals children on scroll with direction, distance and blur controls.
Installation
pnpm dlx shadcn@latest add @viewport/fade-in
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
The code behind the preview above.
import { FadeIn } from "@/components/viewport/fade-in";
export default function FadeInDemo() {
return (
<div className="grid w-full max-w-2xl grid-cols-1 gap-4 sm:grid-cols-3">
{(["left", "bottom", "right"] as const).map((from, i) => (
<FadeIn key={from} from={from} delay={i * 0.12} repeat>
<div className="rounded-2xl border border-border bg-card p-6 text-center">
<p className="text-sm font-medium">From {from}</p>
<p className="mt-1 text-xs text-muted-foreground">Scroll away and back to replay.</p>
</div>
</FadeIn>
))}
</div>
);
}Props
| Prop | Type | Default |
|---|---|---|
| from | "bottom" | "top" | "left" | "right" | "none"Direction the element travels from. | "bottom" |
| distance | numberTravel distance in pixels. | 20 |
| delay | number | 0 |
| duration | number | 0.7 |
| blur | booleanAdd a blur that clears as the element arrives. | true |
| repeat | booleanReplay every time the element re-enters the viewport. | false |
| className | string | — |
| children* | React.ReactNode | — |
Accessibility
- Renders children immediately under reduced motion.
- Content is in the DOM from the start, so it is always crawlable.