A word inside a sentence that changes on a timer. Letters flip in around the X axis out of a blur, one after another, and leave the same way mirrored. It is a server component with no JavaScript: one registered custom property runs from 0 to 1 over the whole cycle, and every letter computes its opacity, rotation and blur from it with clamp(). The surrounding text does not jump: all words share one grid cell, so the component either reserves room for the longest word or tweens its width. Screen readers hear one static variant instead of every change.
Browser Support
Drives the word rotation cycle.
Preview
Build websites
that people enjoy
Installation
Usage
import { RotatingText } from "@/components/ui/rotating-text"
export default function Hero() {
return (
<h1 className="text-4xl font-semibold">
Build{" "}
<RotatingText
words={["websites", "apps", "dashboards", "stores"]}
className="text-primary"
/>{" "}
that people enjoy
</h1>
)
}Examples
Animated width
With widthMode="animate" the gap around the word follows its length instead of staying at the longest one.
Build websites that people enjoy
<RotatingText words={words} widthMode="animate" />Status line
A slower stagger and a heavier blur suit a loading or status label.
<RotatingText
words={["LOADING", "SEARCHING", "SORTING", "DONE"]}
interval={2000}
stagger={0.08}
blur={10}
duration={0.6}
className="text-4xl font-bold tracking-widest"
/>Screen reader label
By default assistive tech reads the first word. Pass srLabel when a summary reads better.
<RotatingText
words={["websites", "apps", "dashboards"]}
srLabel="websites, apps and dashboards"
/>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| words | string[] | - | Words to cycle through |
| interval | number | 2500 | How long each word stays, in ms |
| widthMode | "reserve" | "animate" | "reserve" | reserve keeps the width of the longest word, animate tweens the width to the current one |
| duration | number | 0.5 | Duration of one letter animation, in seconds |
| stagger | number | 0.04 | Delay between letters, in seconds |
| blur | number | 6 | Blur of an entering or leaving letter, in px |
| srLabel | string | words[0] | Static text for screen readers. The first word by default |
| className | string | - | Additional CSS classes |