Rotating Text

Words that take turns in place, each one sliding out as the next slides in.

Rotating, Text, Demo
"use client"

import {
  RotatingText,
  RotatingTextContainer,
} from "@animate-ui/react/primitives/texts/rotating"

export default function RotatingTextDemo({
  delay = 0,
  y = -50,
  duration = 2000,
  align = "none",
}: {
  delay?: number
  y?: number
  duration?: number
  align?: "none" | "start" | "center" | "end"
}) {
  return (
    <RotatingTextContainer
      className="text-4xl font-semibold"
      text={["Rotating", "Text", "Demo"]}
      delay={delay}
      y={y}
      duration={duration}
      align={align === "none" ? undefined : align}
    >
      <RotatingText />
    </RotatingTextContainer>
  )
}

Installation

npm install @animate-ui/react motion
pnpm add @animate-ui/react motion
yarn add @animate-ui/react motion
bun add @animate-ui/react motion

Usage

import {
  RotatingText,
  RotatingTextContainer,
} from '@animate-ui/react/primitives/texts/rotating';

export function Tagline() {
  return (
    <RotatingTextContainer text={['Fast', 'Accessible', 'Animated']}>
      <RotatingText />
    </RotatingTextContainer>
  );
}

Animation

  • After delay (right away by default), the current word slides out by y while fading, then the next one slides in from the other side: 0.3s each on an ease-out, one after the other. The next swaps follow every duration. With no delay, the first word leaves as soon as it mounts, so the second one is the first to show.
  • The cycle pauses off screen and in a hidden tab.
  • <AnimateUIProvider tempo> paces the default transition.
  • Under reduced motion, the words keep taking turns as a crossfade, without travel.
  • With align, the container keeps the width of its longest text, so a word swap never moves the text around it, and each word sits at the start, center or end of that width.
  • Screen readers read every word once, never the cycling one.

API Reference

RotatingTextContainer

PropTypeDefault
text
string | string[]-
duration?
number2000
y?
number-50
delay?
number0
align?
'start' | 'center' | 'end'-
inView?
booleanfalse
inViewMargin?
string'0px'
inViewOnce?
booleantrue
...props?
React.ComponentProps<'div'>-

RotatingText

PropTypeDefault
transition?
Transition{ duration: 0.3, ease: 'easeOut' }
...props?
Omit<HTMLMotionProps<'div'>, 'children'>-

useRotatingText

Returns the container's state inside it: { currentText, y, isInView, label }.

Built by Skyleen. The source code is available on GitHub.

Last updated: 10/18/2026

On this page