Skip to content

Text reveal animations for words and letters

A cascade does not split text. To reveal the words or the letters of a text, wrap each part in an element, and put the elements in a cascade. For the cascade APIs and the interval option, see Animate a list.

Wrap each word in an element:

import { Cascade } from "@awesome-reveal/react";
export function HeadingWords() {
return (
<Cascade as="h2" className="words" interval={60}>
<span>Reveal</span> <span>each</span> <span>word</span>
</Cascade>
);
}

The entrance moves the element with a transform, and an inline element cannot have a transform. So give the words display: inline-block. Select inline to see the words fade in with no movement:

Reveal each word

Reveal each word

display

Your device asks for reduced motion, so the content shows with no animation.

.words span {
display: inline-block;
}
.words span {
display: inline;
}

Split the text with Array.from(text), and put each letter in an element.

import { Cascade } from "@awesome-reveal/react";
export function HeadingLetters({ text }) {
return (
<Cascade as="h2" aria-label={text} from={{ opacity: 0 }} interval={40}>
{Array.from(text, (letter, index) => (
<span key={index} aria-hidden="true">
{letter}
</span>
))}
</Cascade>
);
}

Keep the letters inline. The browser can break a line before and after each inline-block element, so a word of inline-block letters can break between two letters. An inline element cannot move, so give the letters a start state with only opacity, as in the example, or with opacity and blur.

Reveal each letter

Your device asks for reduced motion, so the content shows with no animation.

A screen reader can read each letter element as a separate word. Give the full text to screen readers one time:

  • On an element that can have a name, such as a heading, set aria-label to the full text. Set aria-hidden="true" on each letter. The examples above do this.
  • On an element that cannot have a name, such as a paragraph or a div, put the full text in a visually hidden element. Put the letters in an element with aria-hidden="true", and make it the cascade.

The words need no change. Screen readers read a word in its own element as one word.

  • Array.from splits the text into code points. Use the letter examples only when each character that a reader sees has one code point. Other characters break into pieces, such as some emoji and the Hindi कि.
  • Each letter adds one interval. The last letter starts (count - 1) * interval milliseconds after the first. Split only short text, such as a heading.