Skip to content

Getting started

awesome-reveal hides an element until it enters the viewport, and then animates it. Each framework has its own package. Choose your framework in the tabs below. For a page with no framework, choose JavaScript.

Terminal window
pnpm add @awesome-reveal/react

The package needs React 18 or later.

Put the content in a Reveal component:

import { Reveal } from "@awesome-reveal/react";
<Reveal>
<p>I gently appear as I enter the viewport</p>
</Reveal>;

Reveal renders a div around its children. With no keyframes, the div fades in and moves up.

Each package has a keyframes entry point with the same keyframes factories. Give the result of a factory to the keyframes option:

import { Reveal } from "@awesome-reveal/react";
import { slide } from "@awesome-reveal/react/keyframes";
<Reveal as="section" keyframes={slide({ direction: "left" })} duration={800}>
…
</Reveal>;
  • as sets the tag of the rendered element. Reveal gives its other props and its ref to that element.
  • slide({ direction: "left" }) moves the element to the left as it fades in.
  • duration is in milliseconds. The default is 600.

The other factories are fade(), scale(), blur(), pop() and enter(). See Keyframes.

To animate your own element or component with no wrapper, use the useReveal hook:

Spread getProps(yourProps) on the element. Pass your own ref and style inside getProps, not next to the spread.

import { useReveal } from "@awesome-reveal/react";
import { fade } from "@awesome-reveal/react/keyframes";
function Card() {
const { getProps } = useReveal({
keyframes: fade(),
threshold: 0.3,
});
return (
<article {...getProps({ className: "card", style: { padding: 16 } })}>
…
</article>
);
}

getProps hides the element until the reveal and sets data-reveal. threshold: 0.3 reveals the element when 30% of it is visible.