Text Rotate React component for Tailwind CSS v4
v1.0.0Added in 1.10.0
A rotating word for headlines that cycles through a list of words or short phrases in place, inside a sentence that reflows to fit each one.
Every few seconds the word slides, fades, blurs or flips to the next one, letter by letter if you like, while the sentence reflows to fit it. Hover or focus it to hold the current word when pauseOnHover is on. It waits while the tab is hidden or the text is off screen, screen readers hear the full list once, and with reduced motion on the current word simply stays.
Text Rotate is a Pro React component in the React effect components category, written in TypeScript for React 19 and Tailwind CSS v4. It installs as source with npx wingo-ui@latest add text-rotate, together with Motion presets, Tones, UIProvider and useControllableState and the npm package motion.
Add to a project
Requirements: React 19 and Tailwind CSS v4, in Next.js (App Router or Pages), Vite or React Router. Installation guide · Next.js setup · Vite setup
npx wingo-ui@latest add text-rotatePro item: the CLI needs a Pro account. See plans
Usage
Import TextRotate from @/components/ui/text-rotate.
import { TextRotate } from "@/components/ui/text-rotate"
export function Hero() {
return (
<h1 className="text-5xl font-semibold tracking-tight">
Ship <TextRotate words={["faster", "smarter", "together"]} tone="brand" highlight="pill" />
</h1>
)
}
// Letter by letter with a 3D flip:
// <TextRotate words={["design", "build", "launch"]} effect="flip" by="char" />Props
wordsdefault"["faster", "smarter", "together"]"string[]The words or short phrases to cycle through, in order. A single word just sits still.
intervaldefault2500numberMilliseconds each word stays on screen before the next one comes in.
effectdefault"slide-up""slide-up" | "slide-down" | "fade" | "blur" | "flip"How words swap. Slides and the 3D flip move on a snappy spring; fade and blur cross-fade on a smooth one.
bydefault"word""word" | "char"word swaps the whole word at once; char staggers its letters in and out.
staggerdefault25numberWith by="char", milliseconds between one letter and the next.
tonedefault"inherit""inherit" | "neutral" | "brand" | "success" | "warning" | "danger" | "info"Color of the rotating word. inherit keeps the color of the sentence around it; the tones use the readable soft-foreground shade.
colordefault""stringAny CSS color for the rotating word and its highlight. Replaces the tone. Leave empty to use the tone.
highlightdefault"none""none" | "underline" | "pill"Decoration behind the word that resizes with it: a soft underline, or a rounded pill tinted with the tone.
pauseddefaultfalsebooleanStops the timer and keeps the current word. Changing index still swaps words.
loopdefaulttruebooleanStarts over after the last word. Turn it off to stop on the last one, for a sentence that settles.
pauseOnHoverdefaultfalsebooleanHolds the current word while a mouse is over it or keyboard focus is inside it.
asdefault"span""span" | "div"The root element. span sits inline in a sentence; div for a word on its own line.
defaultIndexdefault0numberThe word shown first when the rotation runs on its own.
indexnumberThe shown word, for a controlled rotation. Pair it with onIndexChange; the timer still asks for the next index.
onIndexChange(index: number) => voidCalled with the next index whenever the word changes, from the timer or from outside.
classNamesPartial<Record<"word" | "char" | "highlight", string>>Extra classes for the rotating word, each letter in char mode, and the highlight box around it.
classNamestringExtra classes for the root element.
refRef<HTMLElement> (a useRef object or an (el) => void callback)The root element.
Parts
TextRotateEffect
typeThe effect names: "slide-up" | "slide-down" | "fade" | "blur" | "flip".
TextRotateBy
typeThe animated unit: "word" | "char".
TextRotateHighlight
typeThe decoration: "none" | "underline" | "pill".
TextRotateTone
typeA tone from lib/tones, or "inherit" to keep the surrounding text color.
TextRotateSlot
typeThe keys of classNames: "word" | "char" | "highlight".
TextRotateProps
typeThe props of TextRotate, plus every attribute of the root element.
Examples
Hero headline
The default slide-up inside an h1; the line reflows as words change length.
Brand pill
tone="brand" with highlight="pill" and a blur swap; pauseOnHover holds the word under the mouse.
Letter flip
by="char" with the 3D flip; each letter turns over 35ms after the one before it.
Controlled with buttons
index and onIndexChange put the rotation in your hands; paused turns the timer off.
Inside a paragraph
A longer phrase in running text, cross-fading every 3 seconds and wrapping on narrow screens.
Dependencies
Files
- components/ui/text-rotate.tsx
FAQ
Is the React Text Rotate component free?
The preview, props and docs are free; copying the source needs a Pro plan. See plans.
How do I install Text Rotate?
Run npx wingo-ui@latest add text-rotate. It also adds the Wingo UI items it builds on (Motion presets, Tones, UIProvider and useControllableState) and the npm package motion. With shadcn, add the @wingo-ui registry with your API key, then run npx shadcn@latest add @wingo-ui/text-rotate.