# Typing Text

> A React typewriter that types a phrase, holds, deletes and moves on, with a blinking accent caret. Starts in view and gives screen readers the plain text.

- Kind: Motion component (Motion)
- Docs: https://ui.minidev.pro/docs/typing-text
- Source (registry JSON with the full file): https://ui.minidev.pro/r/typing-text.json
- License: MIT. One file, yours to edit after install.

## When to use

Use it for a short hero line that types a few phrases. Reach for WordRotate to swap one word in a sentence, MorphingText for a softer melt, and HeroTypedHeadline for a complete typed hero.

## Installation

### shadcn CLI (copies the source into your project)

```bash
npx shadcn@latest add @minidev/typing-text
```

Writes `components/ui/typing-text.tsx` and installs its npm dependencies. Older CLI versions: `npx shadcn@latest add https://ui.minidev.pro/r/typing-text.json`.

### npm package

```bash
npm i minidev-ui-kit motion
```

Add the tokens to your global stylesheet once:

```css
@import "tailwindcss";
@import "minidev-ui-kit/styles.css";
@source "../node_modules/minidev-ui-kit";
```

Next.js also needs `transpilePackages: ["minidev-ui-kit"]` in next.config.

## Import

After the shadcn install:

```tsx
import { TypingText } from "@/components/ui/typing-text"
```

From the npm package:

```tsx
import { TypingText } from "minidev-ui-kit/premium/typing-text"
```

## Usage

```tsx
import { TypingText } from "@/components/ui/typing-text"

export function Example() {
  return (
    <TypingText />
  )
}
```

## Props

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `phrases` | `string[]` | `["Build the MVP.", "Ship it in 30 day...` | no |  |
| `speed` | `number` | `55` | no | Milliseconds per typed character. |
| `hold` | `number` | `1400` | no | Milliseconds to hold a finished phrase. |
| `loop` | `boolean` | `true` | no |  |
| `className` | `string` | - | no |  |

## Examples

### Custom phrases

phrases are typed, held, deleted and replaced in order; the loop restarts after the last one.

```tsx
<TypingText phrases={["Send the invoice.", "Chase it for you.", "Close the books."]} />
```

### Type once

loop={false} types the last phrase and leaves it with the caret blinking; speed is milliseconds per character.

```tsx
<TypingText phrases={["Welcome back, Maya."]} loop={false} speed={40} />
```

### Inside a headline

Set the static words beside it and colour the typed slot with className; hold keeps each finished phrase on screen.

```tsx
<h2 className="flex flex-wrap items-baseline justify-center gap-x-2 text-3xl font-medium tracking-[-0.04em] text-fg sm:text-4xl">
  <span>Lumen is for</span>
  <TypingText phrases={["agencies", "consultants", "studios", "freelancers"]} speed={70} hold={1800} className="text-accent-fg" />
</h2>
```

## Accessibility

- Screen readers get all `phrases` joined once from an `sr-only` span; the typed text and caret are `aria-hidden`.
- Typing only runs while 60% of it is in view.
- Under reduced motion it shows the first phrase in full and the caret does not blink.

## FAQ

### How do I type the phrases once and stop?

Pass `loop={false}`. It types each phrase, deletes it, and stops after the last one is typed, leaving it on screen. `speed` is milliseconds per character (55, with a little random jitter) and `hold` is how long a finished phrase stays (1400).

### Will the typing move the text around it?

Yes. It is an `inline-flex` span whose width follows the typed text. Put it at the end of a line, or give it a fixed width, so nothing after it shifts.

## Rules for generating code

- Use semantic tokens only (bg, surface, sunken, border, fg, fg-muted, fg-subtle, ink, accent, success, warning, danger). Never raw hex or palette steps like blue-500.
- Shadows only from the set: shadow-xs, shadow-sm, shadow-raised, shadow-md, shadow-lg, shadow-overlay.
- Numbers use tabular-nums. Dark mode is the `dark` class on <html>; components never branch on theme.

## Dependencies

- npm: `motion`

## Related

- [Word Rotate](https://ui.minidev.pro/docs/word-rotate/md): Rotates words inside a sentence: the old word lifts and blurs away as the next rises in. The slot keeps the widest word's width so the line never jumps.
- [Morphing Text](https://ui.minidev.pro/docs/morphing-text/md): React headline that cycles through phrases by blurring one into the next on two stacked layers, pauses off screen and shows the first phrase for reduced motion.
- [Hero Typed Headline](https://ui.minidev.pro/docs/hero-typed-headline/md): A centered hero whose headline cycles through rotating words such as dashboards and AI apps with a slide transition. Rotation pauses for reduced motion.
- [Text Scramble](https://ui.minidev.pro/docs/text-scramble/md): A text effect that scrambles random glyphs and resolves to the final string letter by letter when it scrolls into view. Its aria-label keeps the real text.
- [Animated Feature Row](https://ui.minidev.pro/docs/animated-feature-row/md): A row of feature cards that slide up with a staggered delay when scrolled into view. Pass title and description pairs; reduced motion keeps them still.
- [Card Tilt](https://ui.minidev.pro/docs/card-tilt/md): A card that tilts in 3D toward the pointer on springs, with an accent glare that follows the cursor. It stays flat when reduced motion is preferred.

---

All 557 components: https://ui.minidev.pro/llms.txt (full text: https://ui.minidev.pro/llms-full.txt).
