This component no longer exists. It was in Svelte Animations’s manifest when we first indexed it and is not there now — the registry served its inventory on 2026-08-05 and this item was not on it. The install command below will fail. It is kept here because a tutorial somewhere still tells people to run it.
Typing Animation
svelte-animations/typing-animationRemovedBlock
A typewriter effect component that types out text with customizable speed, cursor styles, and support for cycling through multiple words.
Install it
npx shadcn@latest add https://sv-animations.vercel.app/r/typing-animation.jsonSource
1<script lang="ts">2 import { motion, type MotionProps, inView } from "motion-sv";3 import { cn } from "$UTILS$.js";4 import { watch } from "runed";56 interface TypingAnimationProps extends MotionProps {7 content?: string; // Single text string to type8 words?: string[]; // Array of words to cycle through9 class?: string;10 duration?: number;11 typeSpeed?: number;12 deleteSpeed?: number;13 delay?: number;14 pauseDelay?: number;15 loop?: boolean;16 startOnView?: boolean;17 showCursor?: boolean;18 blinkCursor?: boolean;19 cursorStyle?: "line" | "block" | "underscore";20 }2122 let {23 content,24 words,25 class: className,26 duration = 100,27 typeSpeed,28 deleteSpeed,29 delay = 0,30 pauseDelay = 1000,31 loop = false,32 startOnView = true,33 showCursor = true,34 blinkCursor = true,35 cursorStyle = "line",36 ...props37 }: TypingAnimationProps = $props();3839 let displayedText = $state("");40 let currentWordIndex = $state(0);41 let currentCharIndex = $state(0);42 let phase = $state<"typing" | "pause" | "deleting">("typing");4344 let elementRef: HTMLElement | null = $state(null);4546 let wordsToAnimate = $derived(words || (content ? [content] : []));47 let hasMultipleWords = $derived(wordsToAnimate.length > 1);48 let typingSpeed = $derived(typeSpeed || duration);49 let deletingSpeed = $derived(deleteSpeed || typingSpeed / 2);5051 // State: Track if element is in view52 let isInView = $state(false);5354 // Watch elementRef to setup inView detection55 watch(56 () => elementRef,57 () => {58 if (!startOnView) {59 isInView = true;60 return;61 }6263 if (!elementRef) return;6465 // Use motion-sv's inView for detection66 const cleanup = inView(67 elementRef,68 () => {69 isInView = true;70 },71 { amount: 0.3 }72 );7374 return cleanup;75 }76 );7778 // Derived: Should animation start79 let shouldStart = $derived(startOnView ? isInView : true);8081 // Animation loop using watch - only watches shouldStart82 let timeoutId: ReturnType<typeof setTimeout> | undefined;8384 let runAnimation = () => {85 if (!shouldStart || wordsToAnimate.length === 0) return;8687 const currentWord = wordsToAnimate[currentWordIndex] || "";88 const graphemes = Array.from(currentWord);8990 // Calculate delay based on current phase and initial delay91 const timeoutDelay =92 delay > 0 && displayedText === ""93 ? delay94 : phase === "typing"95 ? typingSpeed96 : phase === "deleting"97 ? deletingSpeed98 : pauseDelay;99100 timeoutId = setTimeout(() => {101 switch (phase) {102 case "typing":103// … truncated
What it pulls in
npm packages
