# Typewriter

> Type a phrase one character at a time, or type, erase, and cycle through several, with a blinking caret.

Source: https://www.honestui.com/docs/animated/typewriter

```tsx
"use client";

import { Typewriter } from "@/registry/default/animated/typewriter";

export function TypewriterDemo() {
  return (
    <div className="flex w-full max-w-md flex-col gap-6">
      <h3 className="text-2xl font-semibold tracking-tight text-foreground sm:text-3xl">
        Interfaces that feel{" "}
        <Typewriter
          text={["calm.", "precise.", "accessible.", "honest."]}
          className="text-muted-foreground"
        />
      </h3>
      <div className="rounded-lg border border-border bg-muted/40 px-3 py-2.5 font-mono text-[13px] text-foreground">
        <span className="text-muted-foreground select-none">$ </span>
        <Typewriter text="npx honestui add typewriter" startDelay={600} typeSpeed={45} />
      </div>
    </div>
  );
}

```

## Overview [#overview]

Typewriter reveals text one character at a time behind a caret. With one phrase it types once and stops, which suits a command line or a generated answer. With several, it types each one, holds it, erases it, and moves on to the next, a common way to show the range of a product in a heading.

The caret only blinks while the text is idle. A caret that blinks in the middle of typing looks like a stall.

## Installation [#installation]

<CliBlock commands="[&#x22;typewriter&#x22;]" />

## Usage [#usage]

```tsx
import { Typewriter } from "@/components/animated/typewriter"

<h2>
  Interfaces that feel{" "}
  <Typewriter text={["calm.", "precise.", "honest."]} />
</h2>
```

Type a single line once, after a short delay:

```tsx
<Typewriter text="npx honestui add typewriter" startDelay={600} />
```

Keep the line from reflowing as text is typed by giving the container room for the longest phrase, such as a `min-w-[12ch]` on the parent.

## Accessibility [#accessibility]

Screen readers receive every phrase once, joined with commas, from a visually hidden copy. The animated text and caret are hidden from them, so they never hear partial words. Don't put the only copy of important instructions in a cycling typewriter: sighted readers see each phrase for only a few seconds.

With reduced motion enabled, each phrase appears whole instead of being typed character by character, and the caret stops blinking.

## API Reference [#api-reference]


  ### `text`

type: `string | string[]`

One phrase, or several to type, erase, and cycle through.

  ### `as`

type: `ElementType` · default: `&#x22;span&#x22;`

Element to render.

  ### `typeSpeed`

type: `number` · default: `55`

Milliseconds per typed character.

  ### `deleteSpeed`

type: `number` · default: `28`

Milliseconds per erased character.

  ### `pause`

type: `number` · default: `1600`

Milliseconds a finished phrase stays before it is erased.

  ### `startDelay`

type: `number` · default: `0`

Milliseconds before typing starts.

  ### `loop`

type: `boolean`

Cycles back to the first phrase. Defaults to true when 

    `text`

     is an array.

  ### `startOnView`

type: `boolean` · default: `false`

Waits until the element scrolls into view.

  ### `cursor`

type: `boolean` · default: `true`

Shows the caret.

  ### `keepCursor`

type: `boolean` · default: `true`

Keeps the caret after the last phrase is typed.

  ### `cursorClassName`

type: `string`

Class for the caret, such as a color or width.

  ### `onPhraseComplete`



void">
    Called after each phrase finishes typing.

  ### `className`

type: `string`

Class for the root element.
