Join our Discord Community
Text

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.

Powered by

Loading component...

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

Features

  • Typewriter animation with character-by-character typing at configurable speeds
  • Blinking cursor with smooth opacity transitions and customizable styling using Motion
  • Multiple text support cycles through arrays of strings with erase and retype functionality
  • In-view detection triggers animation when component enters viewport with configurable margins
  • Loop options for continuous animation cycles with customizable hold delays between texts
  • TypeScript support with complete interface definitions for all animation and timing props

Use Cases

This free open source React component works well for:

  • Hero sections - Dynamic headlines that reveal text progressively in Next.js applications
  • Terminal interfaces - Command-line style text display using TypeScript and Tailwind CSS
  • Loading states - Engaging text reveals while content loads in the background
  • Interactive demos - Step-by-step text explanations with realistic typing effects

API Reference

TypingText

PropTypeDefaultDescription
textstring | string[]requiredText content or array of texts to cycle through
durationnumber100Time in milliseconds between each character typing
delaynumber0Initial delay before animation starts in milliseconds
cursorbooleanfalseShow blinking cursor after text
cursorClassNamestring-CSS classes for customizing cursor appearance
loopbooleanfalseEnable continuous cycling through text array
holdDelaynumber1000Time to hold each completed text before erasing (when looping)
inViewbooleanfalseOnly animate when component enters viewport
inViewMarginstring"0px"Margin for in-view detection trigger
inViewOncebooleantrueOnly trigger in-view animation once
animateOnChangebooleantrueReset animation when text prop changes

CursorBlinker

  • Opacity animation - Cycles between 0% and 100% opacity with linear easing
  • Default styling - 1px width, 20px height with theme-aware colors
  • Positioning - Slight vertical translation for proper text alignment

Implementation Notes

  • Uses setTimeout for precise character timing control
  • Automatically cleans up timeouts on component unmount
  • Supports both single strings and arrays for multi-text cycling
  • Cursor animation runs independently using Motion variants
  • In-view detection uses Intersection Observer API for performance
  • Component forwards ref for advanced integration scenarios