Skip to content

Fade, slide and zoom entrance animations

The from option sets the start state of the entrance. The element animates from this state to no offset, no rotation, no blur, a scale of 1 and an opacity of 1.

Set from to "top", "right", "bottom" or "left". The element starts transparent and 24 pixels away from its resting position, on that side. The default is "bottom", so the element moves up.

from

Your device asks for reduced motion, so the content shows with no animation. The dashed outline shows where the entrance starts.

import { Reveal } from "@awesome-reveal/react";
export function SectionTitle() {
return (
<Reveal from="top">
<h2>Hello</h2>
</Reveal>
);
}
import { Reveal } from "@awesome-reveal/react";
export function SectionTitle() {
return (
<Reveal from="right">
<h2>Hello</h2>
</Reveal>
);
}
import { Reveal } from "@awesome-reveal/react";
export function SectionTitle() {
return (
<Reveal from="bottom">
<h2>Hello</h2>
</Reveal>
);
}
import { Reveal } from "@awesome-reveal/react";
export function SectionTitle() {
return (
<Reveal from="left">
<h2>Hello</h2>
</Reveal>
);
}

The distance is always 24 pixels. For a different distance, set a start state.

Set from to an object. The object can have these properties:

Property Type A number is in
opacity number
x number | string pixels
y number | string pixels
scale number
rotate number | string degrees
blur number | string pixels

A string contains a CSS value with its unit, for example "-100%" or "-5deg".

The object sets the complete start state. Only the properties that you set animate. For example, { scale: 0.9 } scales the element with no fade. To add a fade, also set opacity: 0.

from

Your device asks for reduced motion, so the content shows with no animation. The dashed outline shows where the entrance starts.

import { Reveal } from "@awesome-reveal/react";
export function SectionTitle() {
return (
<Reveal from={{ opacity: 0 }}>
<h2>Hello</h2>
</Reveal>
);
}
import { Reveal } from "@awesome-reveal/react";
export function SectionTitle() {
return (
<Reveal from={{ opacity: 0, scale: 0.8 }}>
<h2>Hello</h2>
</Reveal>
);
}
import { Reveal } from "@awesome-reveal/react";
export function SectionTitle() {
return (
<Reveal from={{ opacity: 0, rotate: -8 }}>
<h2>Hello</h2>
</Reveal>
);
}
import { Reveal } from "@awesome-reveal/react";
export function SectionTitle() {
return (
<Reveal from={{ opacity: 0, blur: 8 }}>
<h2>Hello</h2>
</Reveal>
);
}

These start states give common entrances:

Entrance from
Fade only { opacity: 0 }
Zoom in { opacity: 0, scale: 0.8 }
Slide in from far away { opacity: 0, y: 80 }
Slide in by its full width { opacity: 0, x: "-100%" }
Slide in diagonally { opacity: 0, x: -24, y: 24 }
Rotate in { opacity: 0, rotate: -8 }
Blur in { opacity: 0, blur: 8 }

The entrance uses the easing cubic-bezier(0.22, 1, 0.36, 1). The from option cannot change it. For a different easing, use your own keyframes.

  • The element’s own values do not apply during the entrance. The entrance animates the CSS properties translate, scale, rotate, filter and opacity, but only the properties that the start state sets. While the entrance plays, the element’s own values of these properties do not apply. In the JavaScript API, they also do not apply while the element waits. The element’s own transform property applies. To keep an own value, such as rotate: 3deg, put it on an inner element, or use the keyframes option.
  • In the JavaScript API, a start state without opacity: 0 changes the element before it enters. With opacity: 0 and a movement, the element waits at its resting position. Other start states wait at the start state. For example, with { y: 80 }, the element waits 80 pixels lower, so reveal() reveals it later. React, Vue and Astro hide a waiting element at its resting position.
  • A start state with blur runs on the main thread in Chromium. The full entrance runs there, not only the blur, so it can stutter when the main thread is busy. On pages that must stay smooth, use a start state without blur.