Typewriter

Text that types itself out, or arrives word by word, and can cycle through several lines.

Category
Creative
Access
Free with an account
Source
161 lines · one file
States
5 drawn

The decision inside it

Screen readers get the whole text at once

The animation is drawn over the real text and hidden from assistive tech, so nobody hears a sentence one letter at a time, and the space it will take is held from the start.

When to use it

Use Typewriter for a headline that types itself, a line that cycles through options, or text that streams in word by word. Screen readers get the whole text at once. For one rotating word inside a sentence, use Flip Words.

Installation

How you get it

Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.

Use Liro's Typewriter for this.
Install it: npx shadcn@latest add @liro/typewriter
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/typewriter.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.

For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Free components install through the @liro registry with your CLI token: see the Namespaced tab.

Usage

components/hero-title.tsx
import { Typewriter } from "@/components/ui/typewriter";

export function HeroTitle() {
  return (
    <h1 className="text-4xl font-semibold">
      Contracts signed <Typewriter text={["before the meeting ends.", "from any phone.", "without printing."]} />
    </h1>
  );
}

API reference

“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.

Props

Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.

TypeNotes
textstring | string[] YesThe text, or several lines to cycle through.
mode"type" | "fade-words" No"type" letter by letter, or "fade-words" word by word out of a blur. Default "type".
speednumber NoMilliseconds per letter (type) or per word (fade-words). Default 45 or 70.
loopboolean NoStart again after the last line. Default true for several lines, false for one.
cursorboolean NoA blinking caret after the text while typing. Default true in type mode.
startOnViewboolean NoWait until it scrolls into view. Default true.
asReact.ElementType NoThe element to render, e.g. "h1" or "p". Default "span".
pausenumber NoMilliseconds a finished line stays before it is deleted. Default 1600.

Dependencies

npm packages

clsxframer-motiontailwind-merge

Liro foundations, installed alongside it

liro-theme

States

All of them are drawn by the component. None is left for you to design.

  • Typing
  • Cycling
  • Word by word
  • Finished
  • Reduced motion

Accessibility

  • Keyboard reachable throughout, in visual order
  • Focus trapped in overlays, Escape closes them
  • Focus returns to whatever opened it
  • Live regions announce what changed, not that something did
  • Honours prefers-reduced-motion

Responsive behavior

  • Sizes to its container, not the viewport
  • Usable from 320px up
  • Pointer-based interaction, so trackpad and touch both work
  • No hover-only affordances