React Rotating Text
React rotating text with smooth vertical transitions. Cycle through multiple phrases with clean animations using Motion, TypeScript, and shadcn/ui for Next.js apps.
Powered by
Trying to implement text animations?
Join our Discord community for help from other developers.
Ever seen rotating text that spins like a broken carousel or jumps between words like it's having hiccups? Most implementations either fade in/out (boring) or slide horizontally (jarring layout shifts). This component slides text vertically with proper overflow handling, so the rotation looks natural and doesn't break your layout.
Smooth vertical text rotation
Text that cycles through multiple phrases without layout chaos:
Built with TypeScript and shadcn/ui, using Motion for smooth vertical slide transitions. Perfect for React applications that need dynamic text displays. Each text change flows naturally upward, the container maintains consistent dimensions, and you can control timing without fighting CSS keyframes in your Next.js projects.
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
Usage
import { RotatingText } from "@/components/text/rotating-text";
<RotatingText
text={["Build faster", "Ship better", "Scale easier"]}
duration={3000}
transition={{ duration: 0.5, ease: "easeInOut" }}
/>
Why most rotating text implementations suck
Most developers use opacity transitions (text just fades, looks weak) or horizontal sliding (breaks layout when text lengths differ). Others try CSS animations with transform3d but end up with stuttering or weird timing issues in their React components.
This React component uses vertical sliding with AnimatePresence
in "wait" mode—the old text slides up and out while the new text slides up from below. We set overflow: hidden
on the container so the sliding happens invisibly, maintaining clean boundaries. Built for modern JavaScript development workflows with full TypeScript support.
The timing is crucial: 2-3 seconds between rotations gives users time to read, 0.3-0.5s transition keeps it snappy. Too fast and it's distracting, too slow and it feels broken. We handle the interval cleanup automatically so you don't get memory leaks in your Next.js applications.
Features
- Vertical slide transitions that don't break layouts in React applications
- Automatic rotation timing with proper cleanup for Next.js projects
- Container overflow handling for clean text boundaries
- Support for single text or arrays of rotating phrases
- Complete TypeScript support with full type definitions and IntelliSense
- Works seamlessly with shadcn/ui design system and theme colors
- Free open source component that respects reduced motion preferences
- Built for modern JavaScript frameworks with performance optimization
API Reference
RotatingText
Animated text rotation with vertical slide transitions.
Prop | Type | Default | Description |
---|---|---|---|
text | string | string[] | required | Text or array of texts to rotate |
duration | number | 2000 | Time between rotations (ms) |
transition | Transition | { duration: 0.3, ease: 'easeOut' } | Slide animation timing |
y | number | -50 | Vertical slide distance |
containerClassName | string | - | Container CSS classes |
className | string | - | Text element CSS classes |
...props | HTMLAttributes<HTMLDivElement> | - | Standard div attributes |
Timing Guidelines
Optimal rotation timing for different use cases:
Use Case | Duration | Transition | Reasoning |
---|---|---|---|
Hero taglines | 3000ms | 0.4s | Users need time to read |
Feature highlights | 2500ms | 0.3s | Marketing pace |
Loading states | 1500ms | 0.2s | Keep attention during wait |
Subtle accents | 4000ms | 0.5s | Don't compete with content |
Common gotchas
Layout jumps during rotation: Different text lengths cause container size changes in React applications. Set a fixed width or min-width on the container, or use consistent text lengths for stable layouts.
Rotation stops after unmounting: This React component cleans up intervals automatically, but if you're conditionally rendering in Next.js, make sure the parent component stays mounted.
Text slides wrong direction: The y
prop controls slide direction with full TypeScript support. Negative values slide up (default), positive values slide down. Match your design intent.
Animation feels choppy: Default 300ms transition works for most React applications. For longer text, increase to 400-500ms. For quick rotations, decrease to 200ms but not lower in your JavaScript implementations.
Memory leaks with rapid remounts: The component handles cleanup automatically, but avoid rapidly mounting/unmounting rotating text components in React. Cache them or use conditional visibility instead for better performance.
Related text components you will also like
Flip Words
3D word flipping transitions with smooth perspective transforms
Rolling Text
3D character rolling with realistic physics and perspective
Container Text Flip
Animated text container with word cycling and dynamic width
Circular Text
Text arranged in perfect circles with rotation controls
Curved Loop
Text following curved paths with smooth looping animations
Writing Text
Word-by-word reveals with natural reading rhythm and flow
Questions developers actually ask
React Rolling Text
React 3D rolling text with character-by-character reveals. Smooth rotation physics built with Motion, TypeScript, and shadcn/ui for Next.js apps.
React Scrambled Text Effect
Interactive proximity-based text scrambling using GSAP's ScrambleText plugin. Characters scramble when cursor approaches with customizable radius and timing.