3D text flip
Also called text 3D flip, letter flip effect, or hover text flip
A text effect where each letter rotates on its horizontal axis in 3D, one after another, to reveal the same or new text on its other face.
import { useState } from 'react';
import { motion, useReducedMotion } from 'motion/react';
const STAGGER = 0.03; // seconds between letters
const EASE = [0.23, 1, 0.32, 1] as const;
type RowProps = { text: string; shown: boolean; away: number; className?: string };
function Row({ text, shown, away, className }: RowProps) {
const reduceMotion = useReducedMotion();
return (
<span aria-hidden className={`flex [grid-area:1/1] ${className ?? ''}`}>
{[...text].map((char, i) => (
<motion.span
key={i}
className='inline-block backface-hidden'
// Pivot half an em behind the text, so the faces turn like a box.
style={{ transformOrigin: '50% 50% -0.5em', transformPerspective: 600 }}
initial={false}
animate={{ rotateX: shown ? 0 : away }}
transition={
reduceMotion
? { duration: 0 }
: { duration: 0.5, ease: EASE, delay: i * STAGGER }
}
>
{char === ' ' ? '\u00A0' : char}
</motion.span>
))}
</span>
);
}
type FlipLinkProps = { href: string; label: string; hoverLabel: string };
export function FlipLink({ href, label, hoverLabel }: FlipLinkProps) {
const [flipped, setFlipped] = useState(false);
return (
<a
href={href}
onPointerEnter={() => setFlipped(true)}
onPointerLeave={() => setFlipped(false)}
onFocus={() => setFlipped(true)}
onBlur={() => setFlipped(false)}
className='inline-grid text-5xl font-semibold tracking-tight'
>
<span className='sr-only'>{label}</span>
{/* Front letters roll up and away; back letters roll up from below. */}
<Row text={label} shown={!flipped} away={90} />
<Row text={hoverLabel} shown={flipped} away={-90} className='text-blue-600' />
</a>
);
}Add a 3D text flip to the "Get in touch" link in the footer: split the label into letters, stack a second row that reads "Say hello →" in blue in the same spot, and on hover or keyboard focus rotate each front letter from rotateX(0) to rotateX(90deg) while each back letter turns from rotateX(-90deg) to 0, pivoting around a point 0.5em behind the text, over 500ms with cubic-bezier(0.23, 1, 0.32, 1) and a 30ms stagger from left to right. Use a 600px perspective and backface-visibility: hidden, keep the real label for screen readers, and swap the text without rotating when prefers-reduced-motion is set.
Paste into Layerwise or any AI coding tool.
What is 3D text flip?
A 3D text flip splits a label into letters and gives each one two faces, like the sides of a small box. On hover, every letter turns 90 degrees on its X axis with rotateX, one after another, so the front face rolls away and the back face rolls into view. The back can repeat the label in another color or say something new.
It suits links, buttons, and navigation items on playful or portfolio sites, where a quick roll rewards the hover. Keep the stagger short, around 20 to 40ms per letter, so a long label still finishes in about half a second.
Give each letter some perspective and hide faces that turn away with backface-visibility: hidden. Pivoting around a point half an em behind the text, with transform-origin: 50% 50% -0.5em, makes the faces travel like the sides of a box. Keep the real label for screen readers and hide the letter faces with aria-hidden, flip on keyboard focus too, and swap the text without rotating when someone prefers reduced motion.
Often confused with
- 3D flip
- A 3D flip turns a whole card over to show its back. A 3D text flip turns each letter separately, in a staggered wave.
- Rotating words
- Rotating words swap a whole word on a timer while the rest of the sentence stays. A 3D text flip turns each letter of a label, usually on hover.
Related terms
All terms3D flip
A card that turns over in 3D to reveal a second face on its back, built with `rotateY` and `backface-visibility: hidden`.
Perspective
A CSS property that sets how far the viewer sits from a 3D scene, so rotated elements look deep up close and flatter from far away.
Stagger
Animating a group of items one after another with a small delay between each, so they arrive as a cascade.
Rotating words
A headline where one word keeps changing in place, rolling or fading through a short list while the rest of the sentence stays put.
Build it with Layerwise
Describe your app, watch it run in a live preview, and publish it with a database, storage, and sign-in built in.