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
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
Prop | Type | Default | Description |
---|---|---|---|
text | string | string[] | required | Text content or array of texts to cycle through |
duration | number | 100 | Time in milliseconds between each character typing |
delay | number | 0 | Initial delay before animation starts in milliseconds |
cursor | boolean | false | Show blinking cursor after text |
cursorClassName | string | - | CSS classes for customizing cursor appearance |
loop | boolean | false | Enable continuous cycling through text array |
holdDelay | number | 1000 | Time to hold each completed text before erasing (when looping) |
inView | boolean | false | Only animate when component enters viewport |
inViewMargin | string | "0px" | Margin for in-view detection trigger |
inViewOnce | boolean | true | Only trigger in-view animation once |
animateOnChange | boolean | true | Reset 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
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.
Writing Text
Animated text component that reveals words sequentially with typing effect. Perfect for React applications requiring progressive text display with Next.js integration and TypeScript support.