Skip to content
Textlab
1
Browse

ComponentsTyping

Typewriter

Types, deletes and retypes with a caret.

Type it out., Delete it., Try again.

Installation

$ npx shadcn@latest add @textlab/typewriter

Needs @textlab in your components.json. Setup takes a minute.

Usage

usage.tsx
import { Typewriter } from "@/components/textlab/typewriter/typewriter";

<Typewriter words={["for designers", "for engineers", "for everyone"]} reserve />

Variants

barblockunderscore

Props

PropTypeDefaultDescription
words*string[]–Phrases to type in turn.
variant"bar" | "block" | "underscore""bar"Caret shape.
typeSpeednumber70Milliseconds per typed letter, before jitter.
deleteSpeednumber38Milliseconds per deleted letter.
pausenumber1600Milliseconds a finished phrase is held.
loopbooleantrueKeep cycling through the phrases.
humanizebooleantrueSmall, repeatable variations in key timing.
reservebooleanfalseReserve the longest phrase's width so nothing around it moves.
labelstring–What screen readers hear. Defaults to every phrase.
asElementType"span"Rendered element.
trigger"mount" | "inView" | "manual""inView"What starts the animation. manual follows `active`.
delaynumber0Seconds before the first part moves.
reducedMotion"user" | "always" | "never""user"user follows the OS setting; always shows the still version.
classNamestring–Merged onto the root.
onComplete() => void–Called when a one-shot animation finishes.

When to use it

Reach for it

  • Rotating endings on hero lines.
  • Terminal and chat-style interfaces.

Skip it

  • Critical information that must be readable at once.
  • More than a handful of phrases.

Accessibility and motion

Accessibility

  • Screen readers hear every phrase once from a hidden label, not each keystroke.
  • Use reserve in centered layouts so surrounding text does not shift.

Motion

  • The caret is solid while typing or deleting and blinks only at rest.
  • Spaces take a little longer, like a real typist.
Reduced motion. Shows a phrase in full with no typing and no caret.

Performance

  • One timer at a time; no animation frames.
  • The caret blink is a CSS keyframe.