Skip to content

Text animation

The headline enters one word or one letter at a time. Screen readers read the full title one time.

Version 1.0

Build pages that feel alive

Build pages that feel alive

Reveal animations for React, Vue, Astro and plain JavaScript.

Get startedRead the docs

Your system reduces motion, so the preview does not animate. The code still follows your choices.

Split
Effect
Stagger
Fine-tune
600ms
0ms
Hero.jsx
import { Reveal } from "@awesome-reveal/react";
import { slide } from "@awesome-reveal/react/keyframes";
import { Fragment } from "react";
export function Hero({ title }) {
return (
<h1>
<span className="visually-hidden">{title}</span>
<Reveal
as="span"
className="words"
keyframes={slide()}
stagger={80}
aria-hidden="true"
>
{title.split(" ").map((word, index) => (
<Fragment key={index}>
{index > 0 && " "}
<span>{word}</span>
</Fragment>
))}
</Reveal>
</h1>
);
}
styles.css
.visually-hidden {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
}
/* Transforms do not apply to inline elements. */
.words > span {
display: inline-block;
}

Split text is a problem for screen readers: they can read each word or letter as a separate item. The code prevents this in two steps:

  1. The full title is in an element that only screen readers see. visually-hidden is a class in styles.css. It hides the element visually, but keeps it for assistive technology.
  2. The animated copy has aria-hidden.

Then screen readers read the title one time, and find-in-page finds the full title.

  • Choose stagger between 20 and 40 ms for letters, and between 40 and 80 ms for words. A long text with a large value is slow to finish.
  • Use a short duration for letters, for example 400.
  • Use fade() or a small slide({ distance: 12 }). Large movements of many small elements look noisy.
  • With once: false, the text hides and plays again at each entry. See Viewport options.