React text animation examples you can copy
Most text animations in React come down to one trick: split the text into words or letters, wrap each in a motion.span, and stagger their start times. Install Motion with npm install motion and import from motion/react. Effects that just loop, like a typewriter, shimmer or marquee, need only CSS. Below are 12 examples, each with code we compiled and ran.
Animated text is the cheapest way to make a page feel alive. A headline that rises in word by word, a number that counts up, a word that keeps changing: none of these need a big library or a designer. They need about 20 lines each.
Here are 12 text animations for React, from the simplest to the fiddly ones. Each one says what it looks like, when to use it, and gives you code to paste. Where we make a more polished version in Neebarp Vault, our component library, we link to it, so you can see where the idea goes.
Setup, and how we checked the code
The examples that move with JavaScript use Motion, the library that used to be called Framer Motion. The package is now motion and the React import is motion/react, as the Motion docs show. It's MIT licensed and free. The old framer-motion package still exists on npm, but new code should use the new name.
npm install motionWe put every snippet below into a scratch project with React 19.3.1 and motion 14.14.0, type-checked it with TypeScript in strict mode, bundled it with esbuild and ran it in headless Chrome. Then we read back what happened: the words reached full opacity, the rotating word changed, the counter landed on its number, and the scroll example lit up the right words. The code you see is the code that passed.
Using the Next.js App Router? Put "use client"; at the top of any file that uses Motion or React hooks. The CSS-only examples work as server components.
1. Words that rise in one after another
What it looks like: each word of the headline fades in and slides up a little, starting a beat after the one before. Use it for: a hero headline or a section title that should arrive with some ceremony, once.
import { motion } from "motion/react";
export function StaggerWords({ text }: { text: string }) {
return (
<motion.h1
initial="hidden"
animate="show"
variants={{ show: { transition: { staggerChildren: 0.08 } } }}
>
{text.split(" ").map((word, i) => (
<motion.span
key={i}
style={{ display: "inline-block", marginRight: "0.25em" }}
variants={{
hidden: { opacity: 0, y: 24 },
show: { opacity: 1, y: 0, transition: { duration: 0.5, ease: "easeOut" } },
}}
>
{word}
</motion.span>
))}
</motion.h1>
);
}Want it to happen on scroll rather than on load? Swap animate="show" for whileInView="show" and add viewport={{ once: true }}. Our Scroll Text Reveal takes the same idea further, with each word rising out of a soft blur as you scroll and key phrases swept with a highlighter.
2. Letters that come into focus
What it looks like: each letter starts large and blurred and settles sharp, left to right, like a camera pulling focus. Use it for: a short word or a product name. On long text it gets slow and busy.
import { motion } from "motion/react";
export function BlurLetters({ text }: { text: string }) {
return (
<h2 aria-label={text}>
{Array.from(text).map((ch, i) => (
<motion.span
key={i}
aria-hidden
style={{ display: "inline-block", whiteSpace: "pre" }}
initial={{ opacity: 0, filter: "blur(8px)", scale: 1.4 }}
animate={{ opacity: 1, filter: "blur(0px)", scale: 1 }}
transition={{ delay: i * 0.04, duration: 0.4 }}
>
{ch}
</motion.span>
))}
</h2>
);
}3. A rotating word
What it looks like: "Ship faster" becomes "Ship calmer", then "Ship cheaper", each new word sliding up as the old one leaves. Use it for: a hero that has three honest ways to describe one product.
import { useEffect, useState } from "react";
import { AnimatePresence, motion } from "motion/react";
const words = ["faster", "calmer", "cheaper"];
export function RotatingWord() {
const [i, setI] = useState(0);
useEffect(() => {
const id = setInterval(() => setI((n) => (n + 1) % words.length), 2000);
return () => clearInterval(id);
}, []);
return (
<h1>
Ship{" "}
<span style={{ display: "inline-flex", overflow: "hidden", verticalAlign: "bottom" }}>
<AnimatePresence mode="popLayout" initial={false}>
<motion.span
key={words[i]}
initial={{ y: "100%", opacity: 0 }}
animate={{ y: 0, opacity: 1 }}
exit={{ y: "-100%", opacity: 0 }}
transition={{ type: "spring", stiffness: 300, damping: 30 }}
>
{words[i]}
</motion.span>
</AnimatePresence>
</span>
</h1>
);
}For a word swap with more character, see Gravity Word Swap, where each letter drops in and bounces on the baseline, or Rotor Words, which rolls 3D letter cubes from one word to the next.
4. Typewriter, in CSS only
What it looks like: the line types itself out behind a blinking caret. Use it for: a terminal-style line or an install command. It works best on a single line in a monospace font.
import "./typewriter.css";
export function Typewriter() {
return <p className="typewriter">npm install motion ok</p>;
}
/* typewriter.css */
.typewriter {
font-family: ui-monospace, monospace;
width: 22ch; /* the number of characters */
white-space: nowrap;
overflow: hidden;
border-right: 2px solid currentColor;
animation: typing 2.2s steps(22) both, caret 0.8s step-end infinite;
}
@keyframes typing { from { width: 0; } }
@keyframes caret { 50% { border-color: transparent; } }
@media (prefers-reduced-motion: reduce) { .typewriter { animation: none; } }The catch is that it only works with a fixed number of characters. If the text changes, you need JavaScript: add one character at a time with setInterval, the same way the scramble below works.
5. Scramble, then decode
What it looks like: the text starts as random symbols that flicker and settle into the real letters, left to right. Use it for: a tech or security product, or a hover effect on a short label.
import { useEffect, useState } from "react";
const GLYPHS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ#%&*+?";
export function Scramble({ text }: { text: string }) {
const [out, setOut] = useState(text);
useEffect(() => {
let frame = 0;
const id = setInterval(() => {
frame++;
setOut(
Array.from(text, (ch, i) =>
ch === " " || i < frame / 2 ? ch : GLYPHS[Math.floor(Math.random() * GLYPHS.length)]
).join("")
);
if (frame / 2 >= text.length) clearInterval(id);
}, 30);
return () => clearInterval(id);
}, [text]);
return <h2 aria-label={text} style={{ fontFamily: "ui-monospace, monospace" }}>{out}</h2>;
}A monospace font matters here, or the line jiggles in width while it scrambles. For the mechanical cousin of this effect, a real departure board where each cell flips through its letters, see Split-Flap Text.
6. A number that counts up
What it looks like: "0 downloads" runs up to "12,840 downloads" when it scrolls into view, slowing down at the end. Use it for: stats, prices, any figure you want people to notice.
import { useEffect, useRef } from "react";
import { animate, useInView } from "motion/react";
export function CountUp({ to }: { to: number }) {
const ref = useRef<HTMLSpanElement>(null);
const inView = useInView(ref, { once: true });
useEffect(() => {
if (!inView) return;
const controls = animate(0, to, {
duration: 1.6,
ease: "easeOut",
onUpdate: (v) => {
if (ref.current) ref.current.textContent = Math.round(v).toLocaleString();
},
});
return () => controls.stop();
}, [inView, to]);
return <span ref={ref}>0</span>;
}In our run it read 12,840 when it finished, formatted with a comma by toLocaleString(). For a stat that becomes the whole show, Slot Stat Headline puts the number on slot-machine reels with a lever to pull.
7. Shimmering text
What it looks like: a band of light slides across grey text, over and over. Use it for: a loading or "thinking" message, the way AI chat apps show they're working.
import "./shimmer.css";
export function Shimmer() {
return <h2 className="shimmer">Thinking about your question</h2>;
}
/* shimmer.css */
.shimmer {
background: linear-gradient(110deg, #8a8a8a 35%, #fff 50%, #8a8a8a 65%) 0 0 / 250% 100%;
-webkit-background-clip: text;
background-clip: text;
color: transparent;
animation: shimmer 2.5s linear infinite;
}
@keyframes shimmer { to { background-position: -250% 0; } }For gradient type that moves on its own, Riso Bloom prints a word in two drifting fluorescent inks, like a risograph.
8. Words that light up as you scroll
What it looks like: a big paragraph starts dim, and each word brightens in turn as you scroll it up the screen. Use it for: a mission statement or the one paragraph you want read.
import { useRef } from "react";
import { motion, useScroll, useTransform, type MotionValue } from "motion/react";
function Word({ word, progress, range }: { word: string; progress: MotionValue<number>; range: [number, number] }) {
const opacity = useTransform(progress, range, [0.15, 1]);
return <motion.span style={{ opacity }}>{word} </motion.span>;
}
export function ScrollWords({ text }: { text: string }) {
const ref = useRef<HTMLParagraphElement>(null);
const { scrollYProgress } = useScroll({ target: ref, offset: ["start 0.9", "start 0.25"] });
const words = text.split(" ");
return (
<p ref={ref} style={{ fontSize: 40, maxWidth: "20ch" }}>
{words.map((w, i) => (
<Word key={i} word={w} progress={scrollYProgress} range={[i / words.length, (i + 1) / words.length]} />
))}
</p>
);
}When we scrolled the paragraph to the middle of the screen, the first four words were fully lit and the rest were still at 15%, as they should be. Two finished takes on this: Reading Progress Text, which fills the word on your reading line and shows the time left, and Marker Sweep, below.

9. An endless text marquee
What it looks like: a row of big words slides sideways for ever and pauses when you hover. Use it for: a band of services, a slogan, or a divider between sections.
import "./marquee.css";
export function Marquee({ items }: { items: string[] }) {
const row = [...items, ...items]; // two copies, so the -50% loop has no visible jump
return (
<div className="marquee">
<div className="marquee-track">
{row.map((t, i) => <span key={i} aria-hidden={i >= items.length}>{t}</span>)}
</div>
</div>
);
}
/* marquee.css */
.marquee { overflow: hidden; }
.marquee-track { display: flex; width: max-content; animation: marquee 20s linear infinite; }
.marquee-track span { padding-right: 3rem; font-size: 4rem; font-weight: 800; white-space: nowrap; }
.marquee:hover .marquee-track { animation-play-state: paused; }
@keyframes marquee { to { transform: translateX(-50%); } }Momentum Band adds crossed bands that lean into your scroll and can be flung, and Cylinder Marquee wraps the text around a 3D drum you can spin.
10. A highlighter sweep
What it looks like: a yellow marker stroke draws behind a phrase from left to right when it scrolls into view. Use it for: the one claim in a paragraph you want people to remember.
import type { ReactNode } from "react";
import { motion } from "motion/react";
export function Highlight({ children }: { children: ReactNode }) {
return (
<motion.mark
style={{
color: "inherit",
background: "linear-gradient(#ffe066, #ffe066) no-repeat 0 85% / 0% 40%",
}}
whileInView={{ backgroundSize: "100% 40%" }}
viewport={{ once: true, amount: 1 }}
transition={{ duration: 0.8, ease: "easeInOut" }}
>
{children}
</motion.mark>
);
}Fluoro Swipe does this on a loop, flipping each highlighted word to dark ink as the pen passes.
11. Text that draws itself
What it looks like: the outline of each letter is traced as if by a pen, then the letters fill in. Use it for: a signature, a name, or a one-word title.
import "./stroke-draw.css";
export function StrokeDraw({ word }: { word: string }) {
return (
<svg className="draw" viewBox="0 0 600 140" role="img" aria-label={word}>
<text x="10" y="110">{word}</text>
</svg>
);
}
/* stroke-draw.css */
.draw text {
font: 700 96px Georgia, serif;
fill: transparent;
stroke: currentColor;
stroke-width: 1.5;
stroke-dasharray: 600;
stroke-dashoffset: 600;
animation: draw 3s ease forwards, fill 0.6s 2.4s forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fill { to { fill: currentColor; } }All the letters draw at once here, because SVG text is one shape to CSS. Drawing letter by letter, in pen order, needs real single-line paths. That's what Handwriting Text does, with pen lifts and a swash at the end. Quill Trace inks outline lettering behind a moving nib.
12. Letters that jump when you hover
What it looks like: point at a letter and it springs up, grows and changes colour, then bounces back. Use it for: a playful logo, a footer wordmark, a 404 page.
import { motion } from "motion/react";
export function HoverLetters({ text }: { text: string }) {
return (
<h1 aria-label={text}>
{Array.from(text).map((ch, i) => (
<motion.span
key={i}
aria-hidden
style={{ display: "inline-block", whiteSpace: "pre" }}
whileHover={{ y: -12, scale: 1.15, color: "#ff7a45" }}
transition={{ type: "spring", stiffness: 500, damping: 12 }}
>
{ch}
</motion.span>
))}
</h1>
);
}In headless Chrome the hovered letter rose about 12 pixels, scaled up 15% and turned orange, as written. For effects that react to the pointer's distance rather than a direct hover, try Magnetic Headline, Shy Glyphs or Pressure Text, which is one of Vault's free components.
Which one to use where
| Effect | Best place | Needs |
|---|---|---|
| Staggered words | Hero headline | Motion |
| Focus-pull letters | A product name | Motion |
| Rotating word | Hero tagline | Motion |
| Typewriter | A command or one line | CSS |
| Scramble | Short labels, tech brands | React only |
| Count-up | Stats | Motion |
| Shimmer | Loading text | CSS |
| Scroll highlight | A key paragraph | Motion |
| Marquee | Section dividers | CSS |
| Highlighter | One claim in a paragraph | Motion |
| Self-drawing text | Signatures, titles | CSS + SVG |
| Hover letters | Logos, 404 pages | Motion |
A few habits that keep animated text usable
- Respect reduced motion. Add a
prefers-reduced-motionrule to the CSS examples, as the typewriter does. In Motion, wrap your app in<MotionConfig reducedMotion="user">and it turns off transform animations for people who ask for less motion. - Keep the text readable to screen readers. When you split a word into letters, put the full text in an
aria-labeland hide the pieces, as examples 2, 5 and 12 do. - Animate once, not for ever, unless the motion means something, like "loading". A headline that never stops moving is tiring to read.
- Don't shift the layout. Reserve space for text that changes width, or nearby content will jump.
When you want the polished version
We make Neebarp Vault, so weigh this accordingly. Its Text category has 56 kinetic typography components with 124 variants, from vapour and split-flap boards to weight ripples and neon signs. They're plain React and TypeScript with no runtime dependencies, so they don't need Motion at all. Each category has one or two free components, marked Free; one $9 key opens the rest of the 788 components, with lifetime updates (checked on 29 November 2026). Thirteen more are free on 21st.dev.
Questions
Is Framer Motion the same as Motion?
Yes. Framer Motion was renamed Motion. Install the motion package and import from motion/react. The old framer-motion package is still published, but the Motion docs use the new name.
Can I animate text in React without a library?
Yes. Typewriter, shimmer, marquee and self-drawing text above are plain CSS, and the scramble effect is plain React. A library helps most with staggering, exits (like the rotating word) and scroll-linked effects.
How do I make text animate only when it scrolls into view?
With Motion, use whileInView instead of animate, and add viewport={{ once: true }} so it plays once. Example 6 uses useInView for the same job when you need to start your own animation.
Do animated letters hurt accessibility?
They can. Splitting text into letters makes some screen readers spell it out. Put the full text in an aria-label on the parent and mark the pieces aria-hidden, and honour the reduced-motion setting.
NEEBARP