Split text reveal
Headlines rise word by word out of invisible masks with a springy stagger as they scroll into view.
"use client";
import { motion, useReducedMotion, type Variants } from "motion/react";
import type { ElementType } from "react";
import "./split-reveal.css";
type SplitRevealProps = {
text: string;
as?: ElementType;
className?: string;
/** Seconds between each word. */
stagger?: number;
};
/**
* SplitReveal (needs: npm install motion)
* Splits the text into words. Each word sits in a mask (overflow: hidden)
* and slides up from below it, one after another, when scrolled into view.
*/
export function SplitReveal({
text,
as: Tag = "h2",
className = "",
stagger = 0.06,
}: SplitRevealProps) {
const reduce = useReducedMotion();
const words = text.split(" ");
const container: Variants = {
hidden: {},
show: { transition: { staggerChildren: reduce ? 0 : stagger } },
};
const word: Variants = reduce
? {
hidden: { opacity: 0 },
show: { opacity: 1, transition: { duration: 0.4 } },
}
: {
hidden: { y: "110%", rotate: 6 },
show: {
y: "0%",
rotate: 0,
transition: {
type: "spring",
stiffness: 120,
damping: 18,
mass: 0.9,
},
},
};
return (
<Tag className={`gu-split ${className}`}>
<span className="gu-split__sr">{text}</span>
<motion.span
aria-hidden="true"
className="gu-split__words"
variants={container}
initial="hidden"
whileInView="show"
viewport={{ once: true, amount: 0.5 }}
>
{words.map((w, i) => (
<span key={i} className="gu-split__mask">
<motion.span className="gu-split__word" variants={word}>
{w}
</motion.span>
</span>
))}
</motion.span>
</Tag>
);
}
Paste this into ChatGPT, Claude, Cursor, v0, Lovable or Bolt. It describes the layout, motion, colors and accessibility and includes the code, so the AI can rebuild it in any framework.
# Build this UI piece: Split text reveal
You are a senior front-end engineer. Recreate the piece below in my project. If I don't say which framework I use, ask once, then build it in that framework (React, Vue, Svelte, Angular, Astro, plain HTML/CSS/JS or anything else). Keep the behavior, motion, colors, spacing and accessibility exactly as described. Keep the code clean and commented for beginners.
## What it is
A headline reveal: the sentence is split into words, each word sits inside its own clipping mask, and the words rise up into view one after another with a gentle spring and a tiny rotation, once the headline scrolls into view.
## Layout and look
- Inherits typography from the heading. Demo: system sans-serif, weight 900, clamp(2rem, 6vw, 4rem), line-height 1, letter-spacing -0.045em.
- Each word: inline-block wrapper with overflow hidden, 0.08em bottom padding (for descenders) and 0.25em right margin.
## Behavior and motion (uses the Motion library: npm install motion)
- Container variant "show" staggers its children by 0.06s.
- Each word starts at y: 110% and rotate: 6deg (origin bottom-left) and springs to y: 0, rotate: 0 (stiffness 120, damping 18, mass 0.9).
- Trigger with whileInView, once, when 50% of the heading is visible.
- If the user's framework has no Motion, recreate with CSS: transform transitions with per-word transition-delay = index × 60ms, triggered by an IntersectionObserver adding a class.
## Touch
Identical on touch devices (scroll-triggered). The demo has a Replay button (44px tall) that remounts the headline.
## Accessibility
- A visually hidden copy of the full sentence is read by screen readers; the animated words are aria-hidden.
- prefers-reduced-motion: no movement; all words fade in together over 0.4s.
## Reference implementation
The original is written in React with one plain CSS file. Dependencies: motion. Translate it faithfully; do not add new libraries unless my framework needs them.
### SplitReveal.tsx
```tsx
"use client";
import { motion, useReducedMotion, type Variants } from "motion/react";
import type { ElementType } from "react";
import "./split-reveal.css";
type SplitRevealProps = {
text: string;
as?: ElementType;
className?: string;
/** Seconds between each word. */
stagger?: number;
};
/**
* SplitReveal (needs: npm install motion)
* Splits the text into words. Each word sits in a mask (overflow: hidden)
* and slides up from below it, one after another, when scrolled into view.
*/
export function SplitReveal({
text,
as: Tag = "h2",
className = "",
stagger = 0.06,
}: SplitRevealProps) {
const reduce = useReducedMotion();
const words = text.split(" ");
const container: Variants = {
hidden: {},
show: { transition: { staggerChildren: reduce ? 0 : stagger } },
};
const word: Variants = reduce
? {
hidden: { opacity: 0 },
show: { opacity: 1, transition: { duration: 0.4 } },
}
: {
hidden: { y: "110%", rotate: 6 },
show: {
y: "0%",
rotate: 0,
transition: {
type: "spring",
stiffness: 120,
damping: 18,
mass: 0.9,
},
},
};
return (
<Tag className={`gu-split ${className}`}>
<span className="gu-split__sr">{text}</span>
<motion.span
aria-hidden="true"
className="gu-split__words"
variants={container}
initial="hidden"
whileInView="show"
viewport={{ once: true, amount: 0.5 }}
>
{words.map((w, i) => (
<span key={i} className="gu-split__mask">
<motion.span className="gu-split__word" variants={word}>
{w}
</motion.span>
</span>
))}
</motion.span>
</Tag>
);
}
```
### split-reveal.css
```css
.gu-split {
margin: 0;
}
.gu-split__words {
display: inline;
}
/* Each word is clipped by its own box, so it appears to rise out of nothing. */
.gu-split__mask {
display: inline-block;
overflow: hidden;
vertical-align: top;
padding-bottom: 0.08em; /* room for descenders like g, p, y */
margin-right: 0.25em;
}
.gu-split__word {
display: inline-block;
transform-origin: 0% 100%;
will-change: transform;
}
.gu-split__sr {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip: rect(0 0 0 0);
white-space: nowrap;
}
```
You might also want
Next piece: Orbit loaderMarker highlight
Animations, beginner
Text scramble
Animations, beginner
Letter scatter headline
Animations, beginner