Skip to main content

Text Typing

The TextTyping component creates a classic typewriter effect that reveals text one character at a time, complete with an animated blinking cursor. Perfect for hero sections, introductions, and dynamic content reveals.

Installation

Import

Usage

Props

string
required
The text to display with the typing animation.
number
default:"100"
Speed of typing in milliseconds per character. Lower values = faster typing.
string
Additional CSS classes. Component uses font-mono by default.

Animation Details

Character Reveal

The text is revealed progressively using substring slicing:

Cursor Animation

The cursor uses Framer Motion for smooth blinking:
The cursor blinks continuously throughout the typing animation and after completion.

Examples

Hero Section

Terminal Interface

Multi-Line Typing

Code Editor Simulation

Testimonial Reveal

Interactive Chat Bot

For the most authentic typewriter effect, use monospace fonts like font-mono or custom terminal fonts.

Speed Guidelines

Cursor Customization

While the component uses a pipe character | by default, you can customize the appearance:

Performance

  • Uses efficient setInterval for character updates
  • Automatic cleanup on unmount
  • Minimal re-renders
  • Framer Motion optimizes cursor animation
Very long text (1000+ characters) with fast typing speeds may impact performance. Consider breaking into multiple components.

Use Cases

  • Hero sections: Eye-catching headlines
  • Terminal interfaces: Code editor simulations
  • Chat bots: Realistic conversation flows
  • Loading states: Progress messages
  • Tutorials: Step-by-step instructions
  • Storytelling: Narrative reveals
  • Command prompts: CLI demonstrations
  • Notifications: System messages

Accessibility

  • Screen readers will announce the complete text
  • Final text is fully selectable
  • Animation completes, leaving readable content
  • Works with keyboard navigation
  • Consider providing a skip option for users sensitive to motion

Best Practices

  • Keep text concise for better impact (< 100 characters)
  • Match typing speed to content tone (slower for dramatic, faster for technical)
  • Ensure sufficient contrast for the cursor
  • Don’t overuse on a single page (1-2 instances maximum)
  • Provide static fallback for users with reduced motion preferences