skip to content
mpkcn

~/components/terminal-window

Terminal Window

A terminal window with title bar and dots that types out commands and their output line by line, then shows your content.

~/project — zsh
$npx mpkcn add terminal-window

Installation

terminal
npx mpkcn add terminal-window
deps:none beyond react· tested with react@19.3.0

Usage

Pass the lines to type. Each line is a command typed after the prompt, then its output. Typing starts when the window scrolls into view.

tsx
import { TerminalWindow } from "@/components/mpkcn/terminal-window";

export function Install() {
  return (
    <TerminalWindow
      title="~/app — zsh"
      lines={[
        { command: "npx mpkcn add boot-screen", output: "✓ created boot-screen.tsx" },
        { command: "pnpm dev", output: "ready on http://localhost:3000" },
      ]}
    />
  );
}

Outputs are React nodes, so they can hold colors, links or whole components. Change the window's key to replay the typing.

Examples

Content after the typing

children appear once every line is typed. Use it for the part people interact with: links, buttons, a form.

~/contact — zsh
$contact --init

Just the chrome

With no lines, it is a plain window frame: set idlePrompt={false} and put anything inside. Add onClose for an "esc" button, or actions for your own.

tsx
<TerminalWindow title="preview.tsx" idlePrompt={false} onClose={() => setOpen(false)}>
  <pre>{code}</pre>
</TerminalWindow>

Props

PropTypeDefaultDescription
titleReactNode"~ — zsh"Text in the title bar.
lines{ command?: string; output?: ReactNode; prompt?: string }[][]Lines typed one after the other. A line without command shows its output right away.
promptstring"$"Prompt in front of every command (a line can override it).
typingSpeednumber35Milliseconds per typed character.
lineDelaynumber300Pause after each line, in milliseconds.
startOnViewbooleantrueWait until the window scrolls into view before typing.
idlePromptbooleantrueShow an empty prompt with a blinking cursor at the end.
dotsbooleantrueShow the three window dots.
actionsReactNode—Extra content on the right of the title bar.
onClose() => void—Adds an "esc" close button that calls it.
onComplete() => void—Called once every line is typed.
ignoreReducedMotionbooleanfalseType even under reduced motion. Only use it behind an explicit action.
childrenReactNode—Shown under the lines once they finish.
classNamestring—Extra classes for the window.
bodyClassNamestring—Extra classes for the body (padding, height).

TerminalCursor, the blinking block, is exported too.

Accessibility

  • Under prefers-reduced-motion: reduce every line appears at once, and the cursor stops blinking.
  • Screen readers get each command in full, never half-typed: the typed text is hidden from them and a visually hidden copy carries the whole command.
  • The dots are decorative and hidden. The close button is a real button labelled "Close" with a visible focus ring.
  • Content passed as children only mounts after the typing, so do not put anything there that must be reachable before it finishes.