//scroll animations
Scroll Reveal
Elements animate into view when they enter the viewport. Supports any Motion variant, configurable thresholds, and a once-only mode.
import { ScrollReveal } from "@/registry/default/motion/scroll-reveal";
const cards = [
{
description: "Composable components that snap together cleanly.",
icon: "◈",
title: "Composable",
},
{
description: "Every animation respects prefers-reduced-motion.",
icon: "⬡",
title: "Accessible",
},
{
description: "Zero runtime overhead — pure CSS where possible.",
icon: "◎",
title: "Performant",
},
];
export default function ScrollRevealCards() {
return (
<div className="flex min-h-50 items-center justify-center px-6">
<div className="grid w-full max-w-2xl grid-cols-1 gap-4 sm:grid-cols-3">
{cards.map((card, i) => (
<ScrollReveal
key={card.title}
transition={{ delay: i * 0.12, duration: 0.5, ease: "easeOut" }}
variants={{
hidden: { opacity: 0, y: 24 },
visible: { opacity: 1, y: 0 },
}}
viewOptions={{ amount: 0.3 }}
>
<div className="rounded-xl border border-border bg-card p-5">
<p className="mb-2 text-2xl">{card.icon}</p>
<h3 className="font-semibold text-foreground">{card.title}</h3>
<p className="mt-1 text-muted-foreground text-sm">
{card.description}
</p>
</div>
</ScrollReveal>
))}
</div>
</div>
);
}
Installation
pnpm dlx shadcn@latest add @cnippet/scroll-reveal
Usage
import { ScrollReveal } from "@/components/motion/scroll-reveal";<ScrollReveal
variants={{ hidden: { opacity: 0, y: 24 }, visible: { opacity: 1, y: 0 } }}
transition={{ duration: 0.5, ease: "easeOut" }}
>
<YourContent />
</ScrollReveal>Anatomy
<ScrollReveal once> {/* motion element that animates from "hidden" to "visible" */}
<YourContent />
</ScrollReveal>Good to know
- The animation plays when the element enters the viewport. Tune when that happens with
viewOptions(Motion'suseInViewoptions, e.g.{ amount: 0.5 }). - Without
once, it animates out again when it leaves the viewport and back in on return. variantsneeds both ahiddenand avisiblestate. The default is a simple fade.- When the user has turned on reduced motion, content appears in its
visiblestate straight away when it enters the viewport.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | Content to reveal |
variants | { hidden: Variant; visible: Variant } | { hidden: { opacity: 0 }, visible: { opacity: 1 } } | Motion variants for the hidden and visible states |
transition | Transition | — | Transition applied to the visible state |
viewOptions | UseInViewOptions | — | Options passed to Motion's useInView (e.g. amount, margin) |
as | React.ElementType | "div" | HTML element or component to render as |
once | boolean | — | When true, the element stays visible after the first reveal and never hides again |
Examples
Feature Cards
Three cards slide up and fade in with staggered delay values as they enter the viewport. Each card is its own ScrollReveal instance.
import { ScrollReveal } from "@/registry/default/motion/scroll-reveal";
const cards = [
{
description: "Composable components that snap together cleanly.",
icon: "◈",
title: "Composable",
},
{
description: "Every animation respects prefers-reduced-motion.",
icon: "⬡",
title: "Accessible",
},
{
description: "Zero runtime overhead — pure CSS where possible.",
icon: "◎",
title: "Performant",
},
];
export default function ScrollRevealCards() {
return (
<div className="flex min-h-50 items-center justify-center px-6">
<div className="grid w-full max-w-2xl grid-cols-1 gap-4 sm:grid-cols-3">
{cards.map((card, i) => (
<ScrollReveal
key={card.title}
transition={{ delay: i * 0.12, duration: 0.5, ease: "easeOut" }}
variants={{
hidden: { opacity: 0, y: 24 },
visible: { opacity: 1, y: 0 },
}}
viewOptions={{ amount: 0.3 }}
>
<div className="rounded-xl border border-border bg-card p-5">
<p className="mb-2 text-2xl">{card.icon}</p>
<h3 className="font-semibold text-foreground">{card.title}</h3>
<p className="mt-1 text-muted-foreground text-sm">
{card.description}
</p>
</div>
</ScrollReveal>
))}
</div>
</div>
);
}
Feature Section (Split Layout)
A two-column layout where the image slides in from the left and the text from the right, creating a balanced split reveal.
import { ScrollReveal } from "@/registry/default/motion/scroll-reveal";
export default function ScrollRevealFeatureSection() {
return (
<div className="flex min-h-50 items-center justify-center px-6">
<div className="flex w-full max-w-2xl flex-col items-center gap-6 sm:flex-row sm:gap-10">
<ScrollReveal
transition={{ duration: 0.6, ease: "easeOut" }}
variants={{
hidden: { opacity: 0, x: -32 },
visible: { opacity: 1, x: 0 },
}}
viewOptions={{ amount: 0.4 }}
>
<div className="flex h-36 w-full items-center justify-center rounded-2xl border border-border bg-gradient-to-br from-violet-500/10 to-purple-500/5 sm:h-44 sm:w-56">
<span className="text-5xl">✦</span>
</div>
</ScrollReveal>
<ScrollReveal
transition={{ delay: 0.15, duration: 0.6, ease: "easeOut" }}
variants={{
hidden: { opacity: 0, x: 32 },
visible: { opacity: 1, x: 0 },
}}
viewOptions={{ amount: 0.4 }}
>
<div className="flex-1">
<p className="font-semibold text-primary text-xs uppercase tracking-widest">
New
</p>
<h2 className="mt-1 font-bold text-2xl text-foreground">
Motion-first design system
</h2>
<p className="mt-2 text-muted-foreground text-sm leading-relaxed">
164 animated components built on Motion and Tailwind — ready to
drop into your next project and customise in seconds.
</p>
</div>
</ScrollReveal>
</div>
</div>
);
}
Stepped List
Each list item slides in from the left with an incrementing delay, building a step-by-step visual sequence on scroll.
import { ScrollReveal } from "@/registry/default/motion/scroll-reveal";
const items = [
"Pick a component",
"Run the CLI command",
"Paste into your project",
"Customise props & styles",
"Ship to production",
];
export default function ScrollRevealList() {
return (
<div className="flex min-h-50 items-center justify-center px-6">
<ol className="w-full max-w-xs space-y-2">
{items.map((item, i) => (
<ScrollReveal
as="li"
key={item}
transition={{ delay: i * 0.1, duration: 0.45, ease: "easeOut" }}
variants={{
hidden: { opacity: 0, x: -20 },
visible: { opacity: 1, x: 0 },
}}
viewOptions={{ amount: 0.5 }}
>
<div className="flex items-center gap-3 rounded-lg border border-border bg-card px-4 py-3">
<span className="flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-primary font-bold text-[10px] text-primary-foreground">
{i + 1}
</span>
<span className="font-medium text-foreground text-sm">
{item}
</span>
</div>
</ScrollReveal>
))}
</ol>
</div>
);
}