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.
Slide in from a side
Section titled “Slide in from a side”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.
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> );}<script setup>import { Reveal } from "@awesome-reveal/vue";</script>
<template> <Reveal from="top"> <h2>Hello</h2> </Reveal></template><script setup>import { Reveal } from "@awesome-reveal/vue";</script>
<template> <Reveal from="right"> <h2>Hello</h2> </Reveal></template><script setup>import { Reveal } from "@awesome-reveal/vue";</script>
<template> <Reveal from="bottom"> <h2>Hello</h2> </Reveal></template><script setup>import { Reveal } from "@awesome-reveal/vue";</script>
<template> <Reveal from="left"> <h2>Hello</h2> </Reveal></template>---import { Reveal } from "@awesome-reveal/astro";---
<Reveal from="top"> <h2>Hello</h2></Reveal>---import { Reveal } from "@awesome-reveal/astro";---
<Reveal from="right"> <h2>Hello</h2></Reveal>---import { Reveal } from "@awesome-reveal/astro";---
<Reveal from="bottom"> <h2>Hello</h2></Reveal>---import { Reveal } from "@awesome-reveal/astro";---
<Reveal from="left"> <h2>Hello</h2></Reveal>import { reveal } from "@awesome-reveal/core";
reveal("h2", { from: "top" });import { reveal } from "@awesome-reveal/core";
reveal("h2", { from: "right" });import { reveal } from "@awesome-reveal/core";
reveal("h2", { from: "bottom" });import { reveal } from "@awesome-reveal/core";
reveal("h2", { from: "left" });The distance is always 24 pixels. For a different distance, set a start state.
Zoom, rotate and blur with a start state
Section titled “Zoom, rotate and blur with 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.
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> );}<script setup>import { Reveal } from "@awesome-reveal/vue";</script>
<template> <Reveal :from="{ opacity: 0 }"> <h2>Hello</h2> </Reveal></template><script setup>import { Reveal } from "@awesome-reveal/vue";</script>
<template> <Reveal :from="{ opacity: 0, scale: 0.8 }"> <h2>Hello</h2> </Reveal></template><script setup>import { Reveal } from "@awesome-reveal/vue";</script>
<template> <Reveal :from="{ opacity: 0, rotate: -8 }"> <h2>Hello</h2> </Reveal></template><script setup>import { Reveal } from "@awesome-reveal/vue";</script>
<template> <Reveal :from="{ opacity: 0, blur: 8 }"> <h2>Hello</h2> </Reveal></template>---import { Reveal } from "@awesome-reveal/astro";---
<Reveal from={{ opacity: 0 }}> <h2>Hello</h2></Reveal>---import { Reveal } from "@awesome-reveal/astro";---
<Reveal from={{ opacity: 0, scale: 0.8 }}> <h2>Hello</h2></Reveal>---import { Reveal } from "@awesome-reveal/astro";---
<Reveal from={{ opacity: 0, rotate: -8 }}> <h2>Hello</h2></Reveal>---import { Reveal } from "@awesome-reveal/astro";---
<Reveal from={{ opacity: 0, blur: 8 }}> <h2>Hello</h2></Reveal>import { reveal } from "@awesome-reveal/core";
reveal("h2", { from: { opacity: 0 } });import { reveal } from "@awesome-reveal/core";
reveal("h2", { from: { opacity: 0, scale: 0.8 } });import { reveal } from "@awesome-reveal/core";
reveal("h2", { from: { opacity: 0, rotate: -8 } });import { reveal } from "@awesome-reveal/core";
reveal("h2", { from: { opacity: 0, blur: 8 } });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 easing
Section titled “The easing”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.
Things to know
Section titled “Things to know”- The element’s own values do not apply during the entrance. The entrance animates the CSS properties
translate,scale,rotate,filterandopacity, 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 owntransformproperty applies. To keep an own value, such asrotate: 3deg, put it on an inner element, or use thekeyframesoption. - In the JavaScript API, a start state without
opacity: 0changes the element before it enters. Withopacity: 0and 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, soreveal()reveals it later. React, Vue and Astro hide a waiting element at its resting position. - A start state with
blurruns 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 withoutblur.