Join our Discord Community
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

Loading component...

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

Loading component...

Lines Animation

Loading component...

Custom Variants

Loading component...

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

PropTypeDefaultDescription
textstring | string[]requiredText content or array of lines to animate
type'chars' | 'words' | 'lines''chars'How to split the text for animation
motionVariantsMotionVariants-Custom animation variants for elements
inViewbooleanfalseEnable intersection observer triggering
inViewMarginstring'0px'Margin for intersection observer
inViewOncebooleantrueTrigger animation only once when in view
delaynumber0Delay before starting animation (milliseconds)
classNamestring-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