Text Typing - Smooth Typewriter Animation Component

A smooth text typing animation component that cycles through an array of texts with typewriter effect. Features customizable cursor styles, typing/deleting speeds, infinite loop, and Framer Motion animations. Perfect for hero sections, portfolios, and dynamic content.

Installation

npx shadcn@latest add "https://ui-struct.vercel.app/r/text-typing"

Usage

import TextTyping from "@/components/ui/text-typing";
<TextTyping
texts={['Developer', 'Designer', 'Creator']}
typingSpeed={80}
cursorStyle="bar"
/>

Preview

Watch the text type and delete in a smooth infinite loop.

Loading preview...

Cursor Styles

Three cursor styles to match your design aesthetic.

Loading preview...
Cursor StyleDescription
barClassic blinking vertical bar
underscoreTerminal-style underscore
blockBlock cursor like text editors

Typing Speed

Control how fast text types and deletes.

Loading preview...
SpeedTypingDeletingUse Case
Fast30ms20msQuick, energetic feel
Normal80ms50msNatural typing speed
Slow150ms80msDramatic, deliberate
Very Slow250ms100msCinematic effect

Hero Section

Perfect for portfolio and landing page hero sections.

Loading preview...

Gradient & Neon Effects

Combine with CSS gradients and glow effects for stunning visuals.

Loading preview...

Terminal Style

Classic terminal/command line aesthetic.

Loading preview...

Chat Interface

Simulated chat typing effect.

Loading preview...

Code Editor

Code editor style with syntax highlighting.

Loading preview...

Component Showcase

Various use cases in different contexts.

Loading preview...

Props

PropTypeDefaultDescription
textsstring[]-Array of texts to cycle through
classNamestring''Additional CSS classes
typingSpeednumber80Typing speed in milliseconds
deletingSpeednumber50Deleting speed in milliseconds
pauseDurationnumber1500Pause after typing completes (ms)
cursorbooleantrueShow/hide cursor
cursorStyle'bar' | 'underscore' | 'block''bar'Cursor style
cursorColorstring'currentColor'Cursor color
cursorBlinkSpeednumber0.8Cursor blink duration (seconds)
loopbooleantrueLoop through texts infinitely
onComplete() => void-Callback when loop finishes (if loop=false)

Examples

Basic Usage

<TextTyping texts={['Hello', 'World']} />

Custom Styling

<span className="text-2xl font-bold">
I am a{' '}
<TextTyping
texts={['Developer', 'Designer', 'Creator']}
className="text-blue-500"
typingSpeed={100}
cursorColor="#3B82F6"
/>
</span>

With Gradient Text

<span className="text-transparent bg-clip-text bg-gradient-to-r from-purple-500 to-pink-500">
<TextTyping
texts={['Amazing', 'Beautiful', 'Stunning']}
cursorColor="#A855F7"
/>
</span>

Terminal Style

<div className="font-mono bg-black text-green-400 p-4">
<span>$ </span>
<TextTyping
texts={['npm install', 'yarn add', 'pnpm add']}
cursorStyle="block"
cursorColor="#22C55E"
typingSpeed={50}
/>
</div>

Without Loop

<TextTyping
texts={['Loading complete!']}
loop={false}
onComplete={() => console.log('Done!')}
/>

Performance Tips

  1. Keep the texts array reasonably sized
  2. Avoid very fast typing speeds (< 20ms) on mobile
  3. Use appropriate pauseDuration for readability

Full Code

Loading preview...