Overview
Thetype-writer-effect.tsx file exports two typewriter animation components:
TypewriterEffect- Character-by-character reveal with staggered animationTypewriterEffectSmooth- Smooth width-based reveal animation
Source Location
/workspace/source/src/app/components/ui/type-writer-effect.tsx
TypewriterEffect Component
Overview
Reveals text character by character with a staggered animation. Each character fades in and expands from hidden to visible when the component enters the viewport.Visual Behavior
- Characters start hidden and with 0 opacity
- Animate to visible with 100ms stagger delay between each character
- Uses
useInViewhook to trigger animation on scroll - Includes animated blinking cursor at the end
Props
Array of word objects to animate. Each word can have custom styling.
Additional classes for the outer container
Additional classes for the cursor element
Type Definition
From/workspace/source/src/app/components/ui/type-writer-effect.tsx:7-18:
Animation Details
From/workspace/source/src/app/components/ui/type-writer-effect.tsx:27-45:
Key animation properties:
- Duration: 0.3 seconds per character
- Stagger delay: 0.1 seconds (100ms) between each character
- Easing: easeInOut for smooth acceleration/deceleration
- Trigger: Animation starts when component enters viewport
Usage Example
From/workspace/source/src/app/components/Navigation.tsx:12,48-54:
Default Styling
Container
Character Spans
Cursor
Cursor Animation
From/workspace/source/src/app/components/ui/type-writer-effect.tsx:80-96:
TypewriterEffectSmooth Component
Overview
Creates a smooth reveal animation by animating the width of a container from 0% to fit-content. All text appears together rather than character-by-character.Visual Behavior
- Text starts with 0% width (hidden)
- Animates to full width over 2 seconds
- Uses
whileInViewto trigger on scroll - Includes 1-second delay before animation starts
- Features the same blinking cursor effect
Props
Array of word objects to display. Same format as
TypewriterEffect.Additional classes for the outer container
Additional classes for the cursor element
Type Definition
From/workspace/source/src/app/components/ui/type-writer-effect.tsx:101-112:
Animation Details
From/workspace/source/src/app/components/ui/type-writer-effect.tsx:147-160:
Key animation properties:
- Duration: 2 seconds total
- Delay: 1 second before animation starts
- Easing: Linear for consistent speed
- White-space: nowrap prevents text wrapping during animation
Usage Example
Default Styling
Container
Text Wrapper
Cursor
Comparison: TypewriterEffect vs TypewriterEffectSmooth
| Feature | TypewriterEffect | TypewriterEffectSmooth |
|---|---|---|
| Animation Style | Character-by-character stagger | Smooth width expansion |
| Duration | 0.3s per character + stagger | 2s total |
| Initial Delay | None | 1 second |
| Trigger | useInView | whileInView |
| Text Alignment | items-end | space-x-1 |
| Best For | Short text, dramatic reveals | Longer text, smooth reveals |
Customization Examples
Multi-colored Text
Custom Cursor
Faster Animation
Implementation Notes
Character Splitting
Both components split words into character arrays: From/workspace/source/src/app/components/ui/type-writer-effect.tsx:20-25:
Spacing Between Words
A non-breaking space ( ) is added after each word:
Dependencies
framer-motion- Required hooks:motion- For animated elementsstagger- For sequential character animationuseAnimate- For programmatic animationsuseInView- For viewport detection
@/lib/utils- Providescn()utility- React (
useEffect)
Accessibility Considerations
Typewriter animations can be distracting for users with motion sensitivity. Consider respecting
prefers-reduced-motion:Performance Tips
Common Use Cases
- Hero Headlines - Large, attention-grabbing titles
- Navigation Branding - Animated logo text (as seen in the example)
- Section Introductions - Reveal section titles on scroll
- Call-to-Action - Emphasize important messages
- Loading States - Creative alternative to spinners