Text
Splitting Text
Advanced text animation component that splits text into characters, words, or lines with staggered motion effects. Perfect for React applications requiring sophisticated typography animations with Next.js integration and TypeScript support.
Powered by
Installation
npx shadcn@latest add https://www.shadcn.io/registry/splitting-text.json
npx shadcn@latest add https://www.shadcn.io/registry/splitting-text.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/splitting-text.json
bunx shadcn@latest add https://www.shadcn.io/registry/splitting-text.json
Features
- Three splitting modes - Characters, words, or lines with different animation behaviors
- Staggered animations with customizable timing and delay between elements
- Intersection Observer support with configurable margins and single-trigger options
- Custom motion variants with complete control over initial, animate, and transition states
- TypeScript support with comprehensive type definitions and variant interfaces
- shadcn/ui integration using design system utilities and responsive classes
- Flexible text input supporting string or string array for different splitting modes
Examples
Words Animation
Lines Animation
Custom Variants
Use Cases
This free open source React component works well for:
- Hero sections - Animated headlines and taglines built with Next.js
- Content reveals - Progressive text disclosure using TypeScript and Tailwind CSS
- Storytelling interfaces - Narrative text animations with shadcn/ui integration
- Marketing pages - Eye-catching text effects for React applications
- Interactive presentations - Slide-in text effects with motion controls
API Reference
SplittingText
Prop | Type | Default | Description |
---|---|---|---|
text | string | string[] | required | Text content or array of lines to animate |
type | 'chars' | 'words' | 'lines' | 'chars' | How to split the text for animation |
motionVariants | MotionVariants | - | Custom animation variants for elements |
inView | boolean | false | Enable intersection observer triggering |
inViewMargin | string | '0px' | Margin for intersection observer |
inViewOnce | boolean | true | Trigger animation only once when in view |
delay | number | 0 | Delay before starting animation (milliseconds) |
className | string | - | Additional CSS classes for container |
Motion Variants Structure
motionVariants?: {
initial?: Record<string, any>; // Starting state
animate?: Record<string, any>; // End state
transition?: Record<string, any>; // Transition config
stagger?: number; // Custom stagger timing
}
Animation Types
- chars - Splits text into individual characters (default stagger: 0.05s)
- words - Splits text into words preserving spaces (default stagger: 0.2s)
- lines - Treats string array as separate lines (default stagger: 0.3s)
Default Animation Behavior
- Initial state - Elements start 150px right and transparent
- Animate state - Elements move to position with full opacity
- Transition - 0.7s duration with easeOut easing
- Stagger - Progressive timing based on splitting type
Implementation Notes
- Uses intersection observer for scroll-triggered animations when
inView
is enabled - Preserves whitespace for character splitting using
white-space: pre
- Automatically adds spaces between words when using word splitting mode
- Supports line breaks when using lines mode with string arrays
- Built with motion/react for smooth, performant animations
- Elements are wrapped in inline-block spans for proper animation behavior
- Integrates seamlessly with shadcn/ui typography and spacing system
Sliding Number
Animated number display with smooth sliding digit transitions and customizable formatting. Perfect for React applications requiring dynamic counters with Next.js integration and TypeScript support.
Typing Text
Animated typing text component with cursor blinking and in-view detection. Perfect for React applications requiring typewriter effects with Next.js integration and TypeScript support.