# Terminal

> React animated terminal window that types commands and prints output lines in sequence, with colored line kinds, a blinking cursor and a replay button.

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

## When to use

Use it to show an install command or CLI flow on a docs or launch page. Reach for the free TerminalWindow for a static transcript, CodeBlock for copyable code, and ConsoleOutput for streaming logs inside product UI.

## Installation

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

```bash
npx shadcn@latest add @minidev/terminal
```

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

### npm package

```bash
npm i minidev-ui-kit lucide-react 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 { Terminal } from "@/components/ui/terminal"
```

From the npm package:

```tsx
import { Terminal } from "minidev-ui-kit/premium/terminal"
```

## Usage

```tsx
import { Terminal } from "@/components/ui/terminal"

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

## Props

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `lines` | `TerminalLine[]` | `SAMPLE_LINES` | no |  |
| `title` | `string` | `"Terminal"` | no |  |
| `prompt` | `string` | `"❯"` | no | Prompt printed before each command. |
| `typingSpeed` | `number` | `26` | no | Milliseconds per typed character. |
| `lineDelay` | `number` | `160` | no | Milliseconds before each output line prints. |
| `commandDelay` | `number` | `600` | no | Milliseconds before a command starts typing. |
| `loop` | `boolean` | `false` | no | Start over after the last line, with a pause. |
| `replay` | `boolean` | `true` | no | Show the replay button in the title bar. |
| `appearance` | `"dark" \| "auto"` | `"dark"` | no | Stay dark in both themes, or follow the page theme. |
| `onComplete` | `() => void` | - | no | Called once the last line has printed. |
| `className` | `string` | - | no |  |

## Examples

### Deploy transcript

Commands type out and every other kind prints whole; error lines turn red and a per line delay adds a pause before a retry.

```tsx
<Terminal
  title="northwind-api · deploy"
  lines={[
    { kind: "command", text: "lumen deploy --env production" },
    { kind: "info", text: "Building northwind-api@4.2.0" },
    { kind: "success", text: "Compiled 212 modules in 3.1s" },
    { kind: "success", text: "Ran 48 tests, 48 passed" },
    { kind: "error", text: "Migration 0042_add_payout_index timed out after 30s" },
    { kind: "command", text: "lumen deploy --env production --skip-migrations", delay: 900 },
    { kind: "success", text: "Live at https://api.northwind.com" },
  ]}
/>
```

### Light theme, looping

appearance="auto" follows the page theme; loop starts over after a pause and a faster typingSpeed suits short commands.

```tsx
<Terminal
  appearance="auto"
  loop
  replay={false}
  prompt="$"
  typingSpeed={14}
  title="zsh"
  lines={[
    { kind: "command", text: "lumen invoices list --status overdue" },
    { kind: "output", text: "INV-2038  Theo Okafor     $2,415  12 days" },
    { kind: "output", text: "INV-2035  Atlas Freight   $1,120   4 days" },
    { kind: "command", text: "lumen remind INV-2038" },
    { kind: "success", text: "Reminder sent to theo@atlasfreight.com" },
  ]}
/>
```

### On complete

onComplete fires once the last line has printed, so the next step can unlock when the transcript is done.

```tsx
function InstallDemo() {
  const [done, setDone] = React.useState(false)
  return (
    <div className="flex w-full max-w-2xl flex-col items-center gap-4">
      <Terminal
        title="Install the Lumen CLI"
        replay={false}
        onComplete={() => setDone(true)}
        lines={[
          { kind: "command", text: "npm install -g @lumen/cli" },
          { kind: "success", text: "added 1 package in 2s" },
          { kind: "command", text: "lumen login" },
          { kind: "success", text: "Signed in as maya@northwind.com" },
        ]}
      />
      <Button disabled={!done}>Open the dashboard <ArrowRightIcon /></Button>
    </div>
  )
}
```

## Keyboard interactions

| Key | Action |
| --- | --- |
| `Tab` | Moves to the Replay button, the only focusable control. |
| `Enter` or `Space` | On Replay, starts the transcript again from the first line. |

## Accessibility

- The animated body is `aria-hidden`. A screen-reader-only `<pre>` holds the whole transcript, with the prompt before each command, so it is read in full and never half-typed.
- Under `prefers-reduced-motion: reduce`, every line shows at once and no typing timers run. `onComplete` fires straight away.
- The Replay button is labelled "Replay". Pass `replay={false}` to remove it.

## FAQ

### When does the typing start?

When at least 30% of the window is on screen. It pauses when the window scrolls away and carries on where it left off. Set `loop` to start over 2.4 seconds after the last line, and `onComplete` fires each time the last line prints.

### How do I control the timing of each line?

`typingSpeed` is ms per character (26), `commandDelay` is the pause before a command (600) and `lineDelay` the pause before each output line (160). Any line can override its own wait with `delay`.

### Does it run commands or take input?

No. It plays the scripted `lines` you pass and has no input or copy button. For a static transcript use [`TerminalWindow`](https://ui.minidev.pro/docs/terminal-window), and for a command people should copy use [`CodeBlock`](https://ui.minidev.pro/docs/code-block).

### Can it follow the light theme?

Yes. It stays dark in both themes by default; pass `appearance="auto"` to use the page's theme tokens instead.

## 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: `lucide-react`, `motion`

## Related

- [Terminal Window](https://ui.minidev.pro/docs/terminal-window/md): Terminal window frame with traffic light dots, a title bar and a monospace body for commands and output. A Tailwind block for install steps, CLI docs and demos.
- [Code Block](https://ui.minidev.pro/docs/code-block/md): React code block with zero dependency syntax coloring, a language tag, optional filename and line numbers, and a copy button that confirms Copied.
- [Console Output](https://ui.minidev.pro/docs/console-output/md): Scrollable Tailwind console panel in monospace that prints log, warn and error lines with level labels. Uses a log role and is keyboard focusable.
- [Docs Marketing](https://ui.minidev.pro/docs/docs-marketing/md): A React docs landing page with an animated headline, docs search, get started and API buttons, a table of contents and scroll revealed code and callouts.
- [Api Key List](https://ui.minidev.pro/docs/api-key-list/md): React settings panel listing API keys with masked previews, created date badges and a rotate button per key, plus a header action to create a new key.
- [Build Pipeline](https://ui.minidev.pro/docs/build-pipeline/md): CI pipeline view that shows each stage as a chip with success, running, failed or pending icons, joined by connectors. Status text is exposed to screen readers.

---

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