Join our Discord Community
Text

Rotating Text

Animated text component that cycles through multiple strings with smooth transitions. Perfect for React applications requiring dynamic content with Next.js integration and TypeScript support.

Powered by

Loading component...

Installation

npx shadcn@latest add https://www.shadcn.io/registry/rotating-text.json
npx shadcn@latest add https://www.shadcn.io/registry/rotating-text.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/rotating-text.json
bunx shadcn@latest add https://www.shadcn.io/registry/rotating-text.json

Features

  • Smooth text transitions with customizable vertical sliding animations using Motion
  • Array or string support accepting single text or multiple strings for rotation
  • Configurable timing with adjustable duration and transition parameters
  • Overflow handling with built-in container styling for clean text changes
  • TypeScript support with complete interface definitions and prop validation
  • shadcn/ui compatibility using utility classes and flexible styling options

Use Cases

This free open source React component works well for:

  • Hero sections - Dynamic taglines and headlines built with Next.js
  • Feature highlights - Rotating benefits and key points using TypeScript and Tailwind CSS
  • Loading states - Engaging text cycles during content loading
  • Marketing copy - Alternating value propositions and call-to-action text

API Reference

RotatingText

PropTypeDefaultDescription
textstring | string[]requiredSingle text string or array of strings to rotate through
durationnumber2000Duration in milliseconds between text changes
transitionTransition{ duration: 0.3, ease: 'easeOut' }Motion transition configuration
ynumber-50Vertical offset for enter/exit animations
containerClassNamestring-Additional CSS classes for the container element

Transition Options

  • duration - Animation duration for text transitions (in seconds)
  • ease - Easing function for smooth animations
  • delay - Optional delay before animation starts

Implementation Notes

  • Uses AnimatePresence with "wait" mode for smooth transitions
  • Automatic interval management with cleanup on component unmount
  • Overflow hidden container prevents layout shifts during animations
  • Supports both single text display and rotating arrays
  • Compatible with shadcn/ui design tokens and theming
  • Optimized performance with minimal re-renders