React Typing Text Animation
Advanced typewriter effect with variable speed, colored text, GSAP cursor animations. Perfect for React applications requiring realistic typing experiences.
Trying to implement typing text animations?
Join our Discord community for help from other developers.
Most typing animations are predictable and mechanical—fixed speeds with basic cursors that don't feel natural. This component creates realistic typing experiences with variable speeds, smooth GSAP-powered cursor animations, multi-colored text support, and intersection observer triggers for performance optimization.
Advanced typewriter effects with variable speed and colors
Text that types with variable timing, colored sequences, and smooth cursor animations:
Built with TypeScript, GSAP, and Motion for React applications, featuring intersection observer triggers, variable typing speeds, and multi-colored text arrays. The cursor uses smooth GSAP animations and can be customized with both character and bar styles.
Installation
npx shadcn@latest add https://www.shadcn.io/registry/typing-text.json
npx shadcn@latest add https://www.shadcn.io/registry/typing-text.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/typing-text.json
bunx shadcn@latest add https://www.shadcn.io/registry/typing-text.json
Usage
import TypingText from "@/components/text/typing-text";
<TypingText
text={["Beautiful components for React", "Built with shadcn/ui", "Ship faster than ever!"]}
typingSpeed={75}
pauseDuration={1500}
showCursor={true}
cursorCharacter="|"
className="text-4xl font-bold"
textColors={['#3b82f6', '#8b5cf6', '#06b6d4']}
variableSpeed={{ min: 50, max: 120 }}
/>
Why most typing effects feel mechanical
Most developers use fixed timing with basic cursors—predictable animations that don't capture the natural variation of human typing. Real typing has inconsistent speeds, color emphasis, and smooth cursor behavior that traditional components miss.
This React component uses variable speed ranges to simulate natural typing rhythms, GSAP for smooth cursor animations, and support for multi-colored text arrays. The intersection observer ensures animations trigger only when visible, while the flexible cursor system supports both character and bar styles.
The key insight: natural typing isn't uniform. When speed varies organically and colors emphasize different concepts, it creates more engaging and human-feeling text reveals that hold user attention.
Features
- Variable speed typing with configurable min/max ranges for natural rhythm variation
- GSAP-powered smooth cursor animations with customizable blinking duration and easing
- Multi-colored text support with automatic color cycling for different text segments
- Intersection observer integration for performance-optimized scroll-triggered animations
- Flexible cursor system supporting both character (|, _, █) and bar styles
- Reverse typing mode and sentence completion callbacks for advanced interactions
- Complete TypeScript support with extensive prop customization options
- Free open source component compatible with Next.js and shadcn/ui design systems
API Reference
TypingText
Advanced typewriter animation with variable speed, colors, and GSAP cursor animations.
Prop | Type | Default | Description |
---|---|---|---|
text | string | string[] | required | Text or array to type through |
typingSpeed | number | 50 | Base milliseconds per character |
initialDelay | number | 0 | Initial delay before typing starts |
pauseDuration | number | 2000 | Pause before erasing (ms) |
deletingSpeed | number | 30 | Speed of backspacing (ms) |
loop | boolean | true | Cycle through text array |
showCursor | boolean | true | Show blinking cursor |
cursorCharacter | string | React.ReactNode | "|" | Cursor character or custom element |
cursorClassName | string | - | Custom cursor styling |
cursorBlinkDuration | number | 0.5 | GSAP cursor blink duration (s) |
hideCursorWhileTyping | boolean | false | Hide cursor during typing |
textColors | string[] | [] | Colors for each text in array |
variableSpeed | {min: number, max: number} | - | Random speed range |
startOnVisible | boolean | false | Start only when in viewport |
reverseMode | boolean | false | Type text in reverse |
onSentenceComplete | (sentence: string, index: number) => void | - | Callback when sentence finishes |
as | ElementType | 'div' | HTML element to render |
className | string | - | Additional CSS classes |
Cursor Character Options
Different cursor styles for various aesthetics:
Character | Style | Best For | Example |
---|---|---|---|
"|" | Thin bar (default) | Modern, clean interfaces | cursorCharacter="|" |
"_" | Underscore | Retro, terminal style | cursorCharacter="_" |
"█" | Block | Bold, attention-grabbing | cursorCharacter="█" |
"▋" | Half block | Balanced visibility | cursorCharacter="▋" |
Custom | Any character/emoji | Creative, playful | cursorCharacter="🔥" |
Variable Speed Configuration
Natural typing rhythm with randomized timing:
Setting | Configuration | Effect | Best For |
---|---|---|---|
Consistent | typingSpeed={75} | Fixed 75ms per char | Predictable, professional |
Subtle Variation | variableSpeed={{min: 60, max: 90}} | ±15ms variance | Slight humanization |
Natural | variableSpeed={{min: 40, max: 120}} | ±40ms variance | Human-like rhythm |
Dramatic | variableSpeed={{min: 20, max: 200}} | Wide variance | Expressive, artistic |
Common gotchas
Typing feels robotic: Default 100ms works for most cases in React applications. Add slight randomization by varying duration ±20ms, or use different speeds for punctuation vs letters with TypeScript logic.
Cursor doesn't align properly: The cursor uses absolute positioning relative to text height in JavaScript applications. If using custom fonts, you might need to adjust cursor height or line positioning.
Text cycles too quickly: Default 2-second hold gives users time to read in Next.js projects. Longer text needs longer holds (3-4 seconds), shorter text can use 1-1.5 seconds for snappy cycles.
Animation starts before users see it: Always use inView={true}
unless you want immediate typing on page load. Otherwise users miss the effect entirely.
Memory leaks with unmounting: The component cleans up timeouts automatically, but avoid rapidly mounting/unmounting typing components in React applications. Cache them or use conditional visibility instead.
Related text components you will also like
Text Generate Effect
Progressive character generation with realistic typing timing
Writing Text
Word-by-word reveals with natural reading rhythm and flow
Splitting Text
Character, word, or line splitting with perfect timing
Counting Number
Spring-powered number counting with natural acceleration
Decrypted Text
Matrix-style decryption effects with character cycling
Shuffle
Random character shuffling with smooth settling animations
Questions developers actually ask
React True Focus Effect
Spotlight-style text effect with blur transitions and targeting brackets that focus attention on one word at a time. Perfect for emphasis and presentations.
React Variable Proximity Text
Interactive text with dynamic font variation based on cursor proximity. Perfect for React applications requiring engaging typography effects.