Default
It waits until it is on screen, then types at an uneven pace, holding at the comma and the period.
Text that types itself in the typewriter face, with an inked caret. Keys land at uneven speeds and hold at commas and periods; several phrases can go one under the other or be typed, held and backspaced in turn.
npx shadcn@latest add @wobko/typewriterFirst time here? Add the registry to components.json first. How to install
It waits until it is on screen, then types at an uneven pace, holding at the comma and the period.
mode="cycle" types a word, holds it, backspaces it and moves on; loop keeps it going. A block caret, and the sentence still reads once to a screen reader.
A real use: an order confirmation types itself onto a receipt, and onDone brings in the button. `reserve` holds the height of the finished receipt, so the paper does not grow (or move, in a centered stage) as it prints. Print another remounts it with a new key.
An inline element. The animation is aria-hidden; the whole text sits in the accessibility tree once, in a polite live region that only changes when you change `text`. Without JavaScript, or with reduced motion, the finished text is simply there.
| Prop | Type | Default | Description |
|---|---|---|---|
| text | string | string[] | - | What to type. An array is several phrases. |
| mode | "lines" | "cycle" | "lines" | lines: each phrase on its own line. cycle: type a phrase, hold it, backspace it, type the next (a loop or a rotating word). |
| speed | number | 22 | Characters per second, as an average: every key has its own delay. |
| delay / pause | number | 300 / 1400 | ms before it starts, and ms to hold a finished phrase. |
| loop | boolean | false | Start again from an empty page when done. The live region is switched off while it loops, so it is never read twice. |
| cursor | "bar" | "block" | "underscore" | false | "bar" | The caret, drawn with the pen. Solid while typing, blinking when it rests (not blinking with reduced motion). |
| reserve | boolean | false | Keep the room of the finished text (the longest phrase of a cycle) from the first frame, so nothing around it moves while it types. The element becomes an `inline-block` (or the `display` your className sets) with an invisible copy of the finished text in flow and the typed text laid over it. Off, it is an inline element that grows as it types and can sit inside a sentence. |
| startOnView | boolean | true | Wait until it is at least 40 % on screen. |
| onDone | () => void | - | Called when the last character is on the page (never when looping). |
| seed | string | number | - | Pins the caret's hand and the jitter of the words. |
The files the CLI copies into your project.
Loading the source