Elements reveal with animation as they enter the viewport using CSS scroll-driven animations with view() timeline.
Browser Support
Feature
Baseline
Your browser
Scroll-driven animations
Reveals elements as they enter the viewport.
Your browser:
Preview
Scroll down ↓
Installation
Usage
import { RevealOnScroll, RevealOnScrollStyles } from "@/components/effects/reveal-on-scroll"
// Add styles once in your layout
<RevealOnScrollStyles />
// Use component
<RevealOnScroll direction="up">
<div>This reveals from below</div>
</RevealOnScroll>
<RevealOnScroll direction="left" delay={200}>
<div>This reveals from right with delay</div>
</RevealOnScroll>How it works
.reveal-on-scroll {
animation: reveal-up linear both;
animation-timeline: view();
animation-range: entry 0% entry 100%;
}
@keyframes reveal-up {
from {
opacity: 0;
transform: translateY(30px);
}
to {
opacity: 1;
transform: translateY(0);
}
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
| direction | "up" | "down" | "left" | "right" | "fade" | "up" | Animation direction |
| delay | number | 0 | Animation delay in ms |
| duration | number | 600 | Animation duration in ms |
| className | string | - | Additional CSS classes |