JGuang

Typing Animation

Typing Animation · Magic UI

Preview
npx shadcn@latest add https://jiguang132.com/r/magic-ui/typing-animation.json

Some upstream demos use online images, videos or tweets. That content depends on network access and third-party services.

Typing Animation

Install: npx shadcn@latest add https://jiguang132.com/r/magic-ui/typing-animation.json

Use case

Type and optionally delete a string or word sequence.

Native props used by the examples

Extracted from all local examples for this entry, grouped by imported module and native owner, including other Magic components used by compound demos. This is not an exhaustive API or a universal host variant. Inspect spread object declarations and the source types/defaults below.

Owning component propExplanationExample source
TypingAnimation.children (typing-animation)Native child content; keep the owning component's text/element constraints.examples/typing-animation-demo.tsx、examples/typing-animation-demo-4.tsx、examples/typing-animation-demo-5.tsx、examples/typing-animation-demo-7.tsx
TypingAnimation.words (typing-animation)Native word sequence used by rotation or typing.examples/typing-animation-demo-2.tsx、examples/typing-animation-demo-3.tsx、examples/typing-animation-demo-6.tsx、examples/typing-animation-demo-7.tsx、examples/typing-animation-demo-8.tsx
TypingAnimation.loop (typing-animation)Repeat the typing sequence.examples/typing-animation-demo-2.tsx、examples/typing-animation-demo-3.tsx、examples/typing-animation-demo-6.tsx、examples/typing-animation-demo-7.tsx、examples/typing-animation-demo-8.tsx
TypingAnimation.typeSpeed (typing-animation)Typing interval in milliseconds.examples/typing-animation-demo-3.tsx
TypingAnimation.deleteSpeed (typing-animation)Deletion interval in milliseconds.examples/typing-animation-demo-3.tsx
TypingAnimation.pauseDelay (typing-animation)Pause between typing/deletion phases in milliseconds.examples/typing-animation-demo-3.tsx、examples/typing-animation-demo-7.tsx
TypingAnimation.startOnView (typing-animation)Start when the owning element enters its current document viewport.examples/typing-animation-demo-4.tsx
TypingAnimation.showCursor (typing-animation)Show the typing cursor decoration.examples/typing-animation-demo-5.tsx
TypingAnimation.blinkCursor (typing-animation)Enable cursor blinking.examples/typing-animation-demo-7.tsx
TypingAnimation.className (typing-animation)Classes on this native component; initialize Tailwind and its required CSS first.examples/typing-animation-demo-7.tsx、examples/typing-animation-demo-8.tsx
TypingAnimation.cursorStyle (typing-animation)Native cursor style: line, block or underscore.examples/typing-animation-demo-8.tsx

Interaction and state checks

  • Typing Animation Demo — typing-animation-demo
  • Typing Animation Multiple Words — typing-animation-demo-2
  • Typing Animation Custom Speed — typing-animation-demo-3
  • Typing Animation Start on View — typing-animation-demo-4
  • Typing Animation Without Cursor — typing-animation-demo-5
  • Typing Animation Single Play — typing-animation-demo-6
  • Typing Animation Cursor Blinking — typing-animation-demo-7
  • Typing Animation Cursor Styles — typing-animation-demo-8

These names identify real example entries, not new component props or extra components. Check pointer/keyboard behavior, themes, small screens and failures for the selected example. Decorative effects must not invent disabled/error/submission states. Complete example installation includes the actual dependency closure.

Business integration boundary

Use native children/words and timing units; this is scripted text, not streamed server content.

Host and motion setup

Initialize Tailwind CSS v4, semantic CSS variables and the dark variant; import the independent local Registry namespace. Reuse an existing next-themes Provider without substituting JGuang UI/Base UI/HeroUI APIs. Mount effects in view and unmount offscreen; provide static alternatives for unavailable Canvas/WebGL or failed remote media. Respect prefers-reduced-motion and verify timer/RAF/observer/listener cleanup: stopping CSS alone does not prove the engine stopped. Examples provide no backend, login, payment or real AI stream. This practical guide is bilingual; detailed upstream references and demo text retain their original language.

Available examples

typing-animation-demo, typing-animation-demo-2, typing-animation-demo-3, typing-animation-demo-4, typing-animation-demo-5, typing-animation-demo-6, typing-animation-demo-7, typing-animation-demo-8

Demo state and mock data do not provide a backend service. Inspect the component props before wiring real data.

Installation

<Tabs defaultValue="cli"> <TabsList> <TabsTrigger value="cli">CLI</TabsTrigger> <TabsTrigger value="manual">Manual</TabsTrigger> </TabsList> <TabsContent value="cli">
npx shadcn@latest add @magicui/typing-animation
</TabsContent> <TabsContent value="manual"> <Steps>

<Step>Copy and paste the following code into your project.</Step>

<Step>Update the import paths to match your project setup.</Step>

</Steps> </TabsContent> </Tabs>

Examples

Basic Usage

Multiple Words with Loop

Custom Speed

Start on View

Without Cursor

Single Play (No Loop)

Cursor Blinking

Cursor Styles

Usage

import { TypingAnimation } from "@/components/ui/typing-animation"
<TypingAnimation>Hello World! 👋</TypingAnimation>

Props

PropTypeDefaultDescription
childrenstring-Single string to animate
wordsstring[]-Array of strings to type and delete in sequence
classNamestring-The class name to be applied to the component
durationnumber100Duration for each character
typeSpeednumber100Speed of typing animation (ms per character)
deleteSpeednumber50Speed of deleting animation (ms per character)
delaynumber0Delay before animation starts (in ms)
pauseDelaynumber1000Pause duration between words (in ms)
loopbooleanfalseWhether to loop the animation
as"article" | "div" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "li" | "p" | "section" | "span""span"Component to render as
startOnViewbooleantrueStart animation when component is in view
showCursorbooleantrueWhether to show the typing cursor
blinkCursorbooleantrueWhether the cursor should blink
cursorStyle"line" | "block" | "underscore""line"Style of the cursor (like VSCode)

Complete example installation

The component command installs the component. Each example command also includes its actual imported components, native support UI, utilities and pinned dependencies. Helpers are not additional catalog components.

Typing Animation Demo

npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/typing-animation/typing-animation-demo.json

Default import: @/components/magicui/examples/typing-animation-demo

Dependencies: clsx@2.1.1, motion@12.42.2, tailwind-merge@3.6.0

Typing Animation Multiple Words

npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/typing-animation/typing-animation-demo-2.json

Default import: @/components/magicui/examples/typing-animation-demo-2

Dependencies: clsx@2.1.1, motion@12.42.2, tailwind-merge@3.6.0

Typing Animation Custom Speed

npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/typing-animation/typing-animation-demo-3.json

Default import: @/components/magicui/examples/typing-animation-demo-3

Dependencies: clsx@2.1.1, motion@12.42.2, tailwind-merge@3.6.0

Typing Animation Start on View

npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/typing-animation/typing-animation-demo-4.json

Default import: @/components/magicui/examples/typing-animation-demo-4

Dependencies: clsx@2.1.1, motion@12.42.2, tailwind-merge@3.6.0

Typing Animation Without Cursor

npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/typing-animation/typing-animation-demo-5.json

Default import: @/components/magicui/examples/typing-animation-demo-5

Dependencies: clsx@2.1.1, motion@12.42.2, tailwind-merge@3.6.0

Typing Animation Single Play

npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/typing-animation/typing-animation-demo-6.json

Default import: @/components/magicui/examples/typing-animation-demo-6

Dependencies: clsx@2.1.1, motion@12.42.2, tailwind-merge@3.6.0

Typing Animation Cursor Blinking

npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/typing-animation/typing-animation-demo-7.json

Default import: @/components/magicui/examples/typing-animation-demo-7

Dependencies: clsx@2.1.1, motion@12.42.2, tailwind-merge@3.6.0

Typing Animation Cursor Styles

npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/typing-animation/typing-animation-demo-8.json

Default import: @/components/magicui/examples/typing-animation-demo-8

Dependencies: clsx@2.1.1, motion@12.42.2, tailwind-merge@3.6.0

Minimal usage and theme

import Demo from '@/components/magicui/examples/typing-animation-demo';
import { ThemeProvider } from 'next-themes';
export default function Example() {
  return <ThemeProvider attribute="class" defaultTheme="system" enableSystem><Demo /></ThemeProvider>;
}

Initialize Tailwind CSS v4, semantic color variables and the dark variant first. Reuse an existing next-themes provider rather than nesting another. Next Link examples require a Next.js environment; in static Vite projects adapt the demo links to your router without changing the native component API. Some media and tweets require network access. Examples do not supply authentication or backend services.

Source-backed parameter reference

Implementation signatures and types are generated from the pinned local source. Optional props, native inherited types, union branches and never exclusions are preserved. A forwardRef implementation's ref is a React reference, not an additional business prop.

TypingAnimation({
  children,
  words,
  className,
  duration = 100,
  typeSpeed,
  deleteSpeed,
  delay = 0,
  pauseDelay = 1000,
  loop = false,
  as: Component = "span",
  startOnView = true,
  showCursor = true,
  blinkCursor = true,
  cursorStyle = "line",
  ...props
}: TypingAnimationProps)
type MotionElementType = Extract<
  keyof DOMMotionComponents,
  keyof typeof motionElements
>

interface TypingAnimationProps extends Omit<MotionProps, "children"> {
  children?: string
  words?: string[]
  className?: string
  duration?: number
  typeSpeed?: number
  deleteSpeed?: number
  delay?: number
  pauseDelay?: number
  loop?: boolean
  as?: MotionElementType
  startOnView?: boolean
  showCursor?: boolean
  blinkCursor?: boolean
  cursorStyle?: "line" | "block" | "underscore"
}

Destructuring defaults in source

Only defaults written directly in parameter/props destructuring are listed. Conditional expressions, runtime theme and computed values require source inspection; this is not an exhaustive behavior-default list.

// TypingAnimation
duration = 100

// TypingAnimation
delay = 0

// TypingAnimation
pauseDelay = 1000

// TypingAnimation
loop = false

// TypingAnimation
as = "span"

// TypingAnimation
startOnView = true

// TypingAnimation
showCursor = true

// TypingAnimation
blinkCursor = true

// TypingAnimation
cursorStyle = "line"

Native and external types

External types remain defined by React or native dependencies, not manually expanded into guessed props. The installed version's TypeScript definitions are authoritative.

Omit<MotionProps, "children">
MotionProps
Extract<
  keyof DOMMotionComponents,
  keyof typeof motionElements
>
DOMMotionComponents