Words leave upward while the next one rises into place.
Installation
Install the packages
npm install @prequelui/react motion@prequelui/react reuses the primitive library your components already depend on.
Add the component
npx shadcn@latest add https://animate.prequelui.terravidhal.me/r/rotating-text.jsonnpx shadcn@latest add https://animate.prequelui.terravidhal.me/r/rotating-text.json
Turn on the motion
npx @prequelui/cli@latest animate rotating-textThe CLI finds the component through components.json, swaps the import and removes the CSS animation classes that Motion replaces.
Usage
Import the component and compose it exactly like the primitive it wraps. Motion is enabled by default; the tempo prop scales every duration and softens every spring.
import { RotatingText } from "@/components/prequelui/rotating-text";
export default function Demo() {
return (
<div className="flex items-baseline gap-2 text-4xl font-medium">
<span>Make</span>
<RotatingText
texts={["design", "product", "motion"]}
duration={2000}
delay={1400}
align="start"
/>
<span>alive.</span>
</div>
);
}import { RotatingText } from "@/components/prequelui/rotating-text";
export function Variant() {
return (
<RotatingText tempo={1.2}>
…
</RotatingText>
);
}Animation
One word leaves upward while the next rises from below. AnimatePresence waits for the exit to finish before mounting the replacement, so the two words are never visible at the same time.
- Travel: 50 px in both directions, 300 ms ease-out.
- Default cycle: 2 s; the first rotation waits for `delay`.
- The box reserves the width of the longest word to avoid layout jumps.
- Reduced motion keeps only the crossfade.
API Reference
Each part accepts the usual HTML props in addition to the motion props below. No accessibility prop is hidden behind the animation layer.
RotatingText
| Prop | Type | Default |
|---|---|---|
| texts | string[] | — |
| duration | number | 2000 |
| delay | number | 0 |
| y | number | -50 |
| loop | boolean | true |
| align | "start" | "center" | "end" | "start" |