Rotating Text

Words leave upward while the next one rises into place.

rotating-text.tsx

Installation

1

Install the packages

npm install @prequelui/react motion

@prequelui/react reuses the primitive library your components already depend on.

2

Add the component

npx shadcn@latest add https://animate.prequelui.terravidhal.me/r/rotating-text.json

npx shadcn@latest add https://animate.prequelui.terravidhal.me/r/rotating-text.json

3

Turn on the motion

npx @prequelui/cli@latest animate rotating-text

The 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.

rotating-text.tsx
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.
300 ms ease-outtravel 50 pxcycle 2 sreserved width

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

PropTypeDefault
textsstring[]—
durationnumber2000
delaynumber0
ynumber-50
loopbooleantrue
align"start" | "center" | "end""start"

Built by Vidhal. The source is available on GitHub.

Last updated: 11/17/2026