Skip to content

React scroll animations

Use @awesome-reveal/react to add scroll animations to a React app. An element fades and slides in when it scrolls into view. The package does not link an animation to the scroll position, as a parallax effect or a scroll progress bar does.

Terminal window
pnpm add @awesome-reveal/react

For the supported React versions, see Requirements.

Wrap the element in Reveal:

import { Reveal } from "@awesome-reveal/react";
export function Hero() {
return (
<Reveal as="section" from="left">
<h1>Scroll animations in React</h1>
<p>The section fades in from the left.</p>
</Reveal>
);
}

Reveal renders an element around its children. as sets its tag, and from sets the entrance. To fade, zoom, rotate or blur the element in, set a start state.

Cascade reveals its direct children one after the other:

import { Cascade } from "@awesome-reveal/react";
export function Features() {
return (
<Cascade as="ul" from={{ opacity: 0, y: 16 }} interval={120}>
<li>Fast</li>
<li>Small</li>
<li>Accessible</li>
</Cascade>
);
}

For a long list or a tall grid, see Animate a list.

useReveal and useCascade reveal an element that you render, with no wrapper element. Spread the props from getProps() on one DOM element:

import { useReveal } from "@awesome-reveal/react";
export function Card({ title }) {
const { getProps } = useReveal({ from: { opacity: 0, scale: 0.95 } });
return <article {...getProps({ className: "card" })}>{title}</article>;
}

To play the entrance when your state changes, such as when a panel opens, give when. To run code when the element reveals, give onReveal.

To prevent a flash of the content before hydration, see Server rendering.