Typing Animation
Characters appearing in typed animation.
|
import { TypingAnimation } from '@/registry/magicui/typing-animation'
export function TypingAnimationDemo() { return <TypingAnimation>Hello World! 👋</TypingAnimation>}Installation
Section titled “Installation”pnpm dlx shadcn@latest add @magicui-solid/typing-animationbunx shadcn@latest add @magicui-solid/typing-animationyarn dlx shadcn@latest add @magicui-solid/typing-animationnpx shadcn@latest add @magicui-solid/typing-animationExamples
Section titled “Examples”Basic Usage
Section titled “Basic Usage”|
import { TypingAnimation } from '@/registry/magicui/typing-animation'
export function TypingAnimationDemo() { return <TypingAnimation>Hello World! 👋</TypingAnimation>}Multiple Words with Loop
Section titled “Multiple Words with Loop”|
import { TypingAnimation } from '@/registry/magicui/typing-animation'
export function TypingAnimationDemo2() { return <TypingAnimation words={['Design 🎨', 'Build 🔨', 'Ship 🚀']} loop />}Custom Speed
Section titled “Custom Speed”|
import { TypingAnimation } from '@/registry/magicui/typing-animation'
export function TypingAnimationDemo3() { return ( <TypingAnimation words={['Fast typing', 'Slow delete']} typeSpeed={50} deleteSpeed={150} pauseDelay={2000} loop /> )}Start on View
Section titled “Start on View”|
import { TypingAnimation } from '@/registry/magicui/typing-animation'
export function TypingAnimationDemo4() { return <TypingAnimation startOnView>Starts typing when in view</TypingAnimation>}Without Cursor
Section titled “Without Cursor”import { TypingAnimation } from '@/registry/magicui/typing-animation'
export function TypingAnimationDemo5() { return <TypingAnimation showCursor={false}>No cursor shown</TypingAnimation>}Single Play (No Loop)
Section titled “Single Play (No Loop)”|
import { TypingAnimation } from '@/registry/magicui/typing-animation'
export function TypingAnimationDemo6() { return <TypingAnimation words={['First', 'Second', 'Final']} loop={false} />}Cursor Blinking
Section titled “Cursor Blinking”With blinking cursor (default) - watch during pause
|Without blinking cursor - static during pause
|import { TypingAnimation } from '@/registry/magicui/typing-animation'
export function TypingAnimationDemo7() { return ( <div class="flex-1 space-y-8"> <div> <p class="mb-2 text-sm text-muted-foreground"> With blinking cursor (default) - watch during pause </p> <TypingAnimation words={['Type', 'Pause', 'Delete']} blinkCursor={true} pauseDelay={2000} loop class="text-4xl font-bold" > Blinking cursor </TypingAnimation> </div> <div> <p class="mb-2 text-sm text-muted-foreground"> Without blinking cursor - static during pause </p> <TypingAnimation words={['Type', 'Pause', 'Delete']} blinkCursor={false} pauseDelay={2000} loop class="text-4xl font-bold" > Static cursor </TypingAnimation> </div> </div> )}Cursor Styles
Section titled “Cursor Styles”Line cursor (default)
|Block cursor (VSCode style)
▌Underscore cursor
_import { TypingAnimation } from '@/registry/magicui/typing-animation'
export function TypingAnimationDemo8() { return ( <div class="flex-1 space-y-8"> <div> <p class="mb-2 text-sm text-muted-foreground"> Line cursor (default) </p> <TypingAnimation words={['Line cursor']} cursorStyle="line" loop class="text-4xl font-bold" /> </div> <div> <p class="mb-2 text-sm text-muted-foreground"> Block cursor (VSCode style) </p> <TypingAnimation words={['Block cursor']} cursorStyle="block" loop class="text-4xl font-bold" /> </div> <div> <p class="mb-2 text-sm text-muted-foreground">Underscore cursor</p> <TypingAnimation words={['Underscore cursor']} cursorStyle="underscore" loop class="text-4xl font-bold" /> </div> </div> )}Import
Section titled “Import”import { TypingAnimation } from '@/components/magicui/typing-animation'<TypingAnimation>Hello World! 👋</TypingAnimation>| Prop | Type | Default | Description |
|---|---|---|---|
children |
string |
- |
Single string to animate |
words |
string[] |
- |
Array of strings to type and delete in sequence |
class |
string |
- |
The class name to be applied to the component |
duration |
number |
100 |
Duration for each character |
typeSpeed |
number |
100 |
Speed of typing animation (ms per character) |
deleteSpeed |
number |
50 |
Speed of deleting animation (ms per character) |
delay |
number |
0 |
Delay before animation starts (in ms) |
pauseDelay |
number |
1000 |
Pause duration between words (in ms) |
loop |
boolean |
false |
Whether to loop the animation |
as |
ValidComponent |
"span" |
The element to render as |
startOnView |
boolean |
true |
Start animation when component is in view |
showCursor |
boolean |
true |
Whether to show the typing cursor |
blinkCursor |
boolean |
true |
Whether the cursor should blink |
cursorStyle |
"line" "block" "underscore" |
"line" |
Style of the cursor (like VSCode) |
Original:
magicui.design/docs/components/typing-animation