Typing Text
kokonut-ui/type-writerFreeComponent
Animated TypeWritter with multiples options.
Live preview
live · rendered by the registry
Rendered by kokonut-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://kokonutui.com/r/type-writer.jsonSource
1"use client";23/**4 * @author: @dorianbaffier5 * @description: Typewriter6 * @version: 1.0.07 * @date: 2025-06-268 * @license: MIT9 * @website: https://kokonutui.com10 * @github: https://github.com/kokonut-labs/kokonutui11 */1213import { motion } from "motion/react";14import { useEffect, useRef, useState } from "react";1516type TypewriterSequence = {17 text: string;18 deleteAfter?: boolean;19 pauseAfter?: number;20};2122type TypewriterTitleProps = {23 sequences?: TypewriterSequence[];24 typingSpeed?: number;25 startDelay?: number;26 autoLoop?: boolean;27 loopDelay?: number;28 deleteSpeed?: number;29 pauseBeforeDelete?: number;30 naturalVariance?: boolean;31};3233const DEFAULT_SEQUENCES: TypewriterSequence[] = [34 { text: "Typewriter", deleteAfter: true },35 { text: "Multiple Words", deleteAfter: true },36 { text: "Auto Loop", deleteAfter: false },37];3839export default function TypewriterTitle({40 sequences = DEFAULT_SEQUENCES,41 typingSpeed = 50,42 startDelay = 200,43 autoLoop = true,44 loopDelay = 1000,45 deleteSpeed = 30,46 pauseBeforeDelete = 1000,47 naturalVariance = true,48}: TypewriterTitleProps) {49 const [displayText, setDisplayText] = useState("");50 const sequenceIndexRef = useRef(0);51 const charIndexRef = useRef(0);52 const isDeletingRef = useRef(false);53 const timeoutRef = useRef<NodeJS.Timeout | null>(null);5455 // Initialize with the sequences provided56 const sequencesRef = useRef(sequences);57 useEffect(() => {58 sequencesRef.current = sequences;59 }, [sequences]);6061 useEffect(() => {62 const getTypingDelay = () => {63 if (!naturalVariance) {64 return typingSpeed;65 }6667 // More natural human typing pattern68 const random = Math.random();6970 // 10% chance of a longer pause (thinking/hesitation)71 if (random < 0.1) {72 return typingSpeed * 2;73 }7475 // 10% chance of a burst (fast typing)76 if (random > 0.9) {77 return typingSpeed * 0.5;78 }7980 // Standard variance (+/- 40%)81 const variance = 0.4;82 const min = typingSpeed * (1 - variance);83 const max = typingSpeed * (1 + variance);84 return Math.random() * (max - min) + min;85 };8687 const runTypewriter = () => {88 const currentSequence = sequencesRef.current[sequenceIndexRef.current];89 if (!currentSequence) {90 return;91 }9293 if (isDeletingRef.current) {94 if (charIndexRef.current > 0) {95 charIndexRef.current -= 1;96// … truncated
What it pulls in
npm packages
Files it writes
More from kokonut-ui
All 40 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Action Search Baraction-search-bar | kokonut-ui | Components | Free | 2 deps · 2 files | |
| AI Input Searchai-input-search | kokonut-ui | Components | Free | 1 dep · 2 files | |
| AI State Loadingai-loading | kokonut-ui | Components | Free | 1 dep | |
| AI Input Selectorai-prompt | kokonut-ui | Components | Free | 2 deps · 4 files | |
| AI Text Loadingai-text-loading | kokonut-ui | Components | Free | 1 dep | |
| AI Voiceai-voice | kokonut-ui | Components | Free | 2 deps | |
| Apple Activity Cardapple-activity-card | kokonut-ui | Components | Free | 1 dep | |
| Magnet Buttonattract-button | kokonut-ui | Components | Free | 2 deps |
