This component requires the
runed and motion-sv dependencies.Installation
This component requires a CSS keyframe for cursor blinking. The installation command will handle this automatically.
Usage
Examples
Basic Example
Simple typing animation with a single text string.Multiple Words Cycling
Cycle through multiple words with typing and deleting effects.Custom Typing Speed
Control how fast characters appear.Custom Delete Speed
Control the deletion speed independently.Different Cursor Styles
Choose from different cursor appearances.Without Cursor
Hide the cursor completely.Non-Blinking Cursor
Show a static cursor without blinking.Start on View
Begin animation when element enters viewport.With Delay
Delay the start of the animation.Single Play (No Loop)
Type once and stop (don’t delete and restart).Multiple Words with Logo
Combine with other elements for rich layouts.Custom Pause Between Words
Adjust how long to pause before deleting.Props
Single text string to type. Use this OR
words, not both.Array of words to cycle through. Use this OR
content, not both.Speed of typing in milliseconds per character. Lower is faster.
Speed of deleting in milliseconds per character. Defaults to half of
typeSpeed.Deprecated. Use
typeSpeed instead.Delay in milliseconds before animation starts.
Pause duration in milliseconds before deleting text (when using
words).Whether to loop the animation. Only applies to single
content mode.Whether to start animation when element enters viewport.
Whether to show the typing cursor.
Whether the cursor should blink.
The style of cursor to display:
line: Vertical bar|block: Block character▌underscore: Underscore_
Additional CSS classes to apply to the component.
Behavior Modes
Single Content Mode
When usingcontent prop:
- Types out the text once
- Can loop if
loop={true} - No deletion phase
Multiple Words Mode
When usingwords prop:
- Types each word
- Pauses (using
pauseDelay) - Deletes the word
- Moves to next word
- Cycles indefinitely
CSS Animation
The cursor blink animation is added during installation:How It Works
The typing effect uses:- Grapheme splitting: Text is split into graphemes (handles emojis correctly)
- State machine: Cycles through typing, pause, and deleting phases
- Viewport detection: Uses motion-sv’s
inViewfor scroll-triggered animations - Timeout-based: Uses setTimeout for precise character timing
- Reactive state: Svelte 5 runes for reactive state management
Customization
Fast Typing, Slow Delete
Long Pause
Let users read the text longer before deleting.Instant Delete
Delete instantly after typing.Styled Typography
Use Cases
- Hero sections: Dynamic headlines that catch attention
- Job titles: “I’m a Developer | Designer | Creator”
- Feature highlights: Cycle through product features
- Loading states: Show dynamic loading messages
- Search placeholders: “Search for…” with different suggestions
- Role descriptions: Animate job roles or capabilities
- Taglines: Rotate through different brand messages
Best Practices
- Word length: Keep words similar in length for better visual consistency
- Speed balance: Typing slightly faster than deleting feels natural
- Pause duration: Give users time to read (1-2 seconds minimum)
- Word count: 3-5 words work best for cycling
- Font choice: Monospace fonts emphasize the typewriter effect
Accessibility
The component handles text content properly:- The actual text is always present in the DOM
- Screen readers can access the content
- No critical information should rely solely on the typing animation
- Consider providing alternative static text for accessibility
The component uses grapheme splitting, which correctly handles complex characters like emojis, ensuring they type as single units: 👋, 🎉, 🚀