Typing Animation

A customizable typing animation component with support for multiple words, cursor styles, and animation controls.

motion-svruned
|

Installation

pnpm dlx shadcn-svelte@latest add https://sv-animations.vercel.app/r/typing-animation.json

Usage

<script lang="ts">	import { TypingAnimation } from "#lib/components/magic/typing-animation/index.js";</script>
<TypingAnimation content="hello, svelte." class="text-2xl leading-relaxed font-normal tracking-normal" />

Examples

Cursor Blinking

Compare a blinking cursor with a steady cursor.

blinking

|

steady

|

Cursor Styles

Compare line, block, and underscore cursors at the same text size.

line

|

block

▌

underscore

_

Single Play

Cycle through three words once and keep the last word visible.

|

Custom Speed

Type quickly and delete slowly with separate speed controls.

|

Multiple Words

Rotate through a short list of words without extra decoration.

|

Start On View

Type a single line when it enters the viewport.

|

Command Line

Type an installation command once with a block cursor.

▌

Inline Rotation

Keep a sentence still while the final words rotate.

explore |

Props

Typing Animation

A versatile typing animation component with support for single text, multiple words, cursor customization, and animation controls.

NameTypeDefaultDescription
contentstringundefinedSingle text string to type (use this OR words)
wordsstring[]undefinedArray of words to cycle through (use this OR content)
classClassValue""Additional CSS classes to apply
durationnumber100Default duration for typing speed (ms per character)
typeSpeednumberdurationSpeed for typing characters (ms per character)
deleteSpeednumbertypeSpeed / 2Speed for deleting characters (ms per character)
delaynumber0Initial delay before animation starts (ms)
pauseDelaynumber1000Delay between typing and deleting (ms)
loopbooleanfalseWhether to loop the animation continuously
startOnViewbooleantrueStart animation when element enters viewport
showCursorbooleantrueShow the typing cursor
blinkCursorbooleantrueMake the cursor blink during pause
cursorStyle'line' | 'block' | 'underscore''line'Style of the cursor ('line': |, 'block': ▌, 'underscore': _)