Components

Terminal Window

An animated React terminal component: a macOS-style console window that types commands character by character, reveals their output, auto-scrolls and blinks a cursor. Script a session with an array of lines — perfect for install instructions, CLI landing pages and hacker-themed hero sections. Built with Tailwind CSS and Motion.

  • Typing animation
  • Real text in the DOM
  • Loop & replay
  • onComplete callback
  • prefers-reduced-motion
~/projects/duskui — zsh
$ npx shadcn@latest add https://duskui.com/r/terminal-window.json
✔ Checking registry.
✔ Installing dependencies.
✔ Created 1 file:
  - components/dusk/hacker/terminal-window.tsx
$ npm run dev
▲ Next.js 16 — ready on http://localhost:3000
✓ Compiled in 812ms

Installation

$ npx shadcn@latest add https://duskui.com/r/terminal-window.json

Usage

install-steps.tsx
import { TerminalWindow } from "@/components/dusk/hacker/terminal-window"

export function InstallSteps() {
  return (
    <TerminalWindow
      title="zsh"
      lines={[
        { type: "command", text: "npm install motion" },
        "added 3 packages in 1s",
        { text: "✓ Done", className: "text-primary" },
      ]}
    />
  )
}

Examples

Custom prompt & loop

Set a prompt for the whole window (or per line), loop to replay forever, and tune each line with delay, typingSpeed and className.

root@dusk: ~
root@dusk:~# nmap -sV 10.0.0.42
Starting Nmap 7.95
PORT     STATE SERVICE VERSION
22/tcp   open  ssh     OpenSSH 9.6
443/tcp  open  https   nginx 1.27
root@dusk:~# ssh deploy@10.0.0.42
Last login: Mon Nov 23 09:14 from 10.0.0.7

Static

animate={false} renders the finished session straight away — useful for docs and code samples. Make the body fit its content with bodyClassName.

git
$ git log --oneline -3
b4753b8 (HEAD -> main) Merge pull request #1
5567b1f Update dependencies
a46cb9b Add front page and component pages

onComplete

onComplete fires when the last line is shown (on every pass when looping), so you can reveal the next step of a page. Use the replay button in the title bar to run it again.

deploy
$ vercel deploy --prod
Building…
Uploading build outputs…
✓ Production: https://duskui.com

Waiting for the session to finish…

API Reference

A TerminalLine is a string (an output line) or { type?: "command" | "output", text, prompt?, delay?, typingSpeed?, className? }. The window also accepts any <div> prop.

PropTypeDefaultDescription
linesTerminalLine[]—The session to play. Restarts only when its content changes.
titleReactNode"bash"Text in the title bar.
promptstring"$"Prompt shown before commands.
typingSpeednumber42Milliseconds per typed character (slightly randomized).
commandDelaynumber550Pause before each command starts typing, in ms.
outputDelaynumber110Pause before each output line appears, in ms.
startDelaynumber350Pause before the first line, in ms.
animatebooleantrueSet to false to show the finished session immediately.
startOnViewbooleantrueWait until the window is on screen; typing also pauses off-screen.
loopbooleanfalseReplay the session forever.
loopDelaynumber3000Pause between loops, in ms.
replayablebooleantrueShow a replay button in the title bar when finished.
showPromptbooleantrueShow an idle prompt with a blinking cursor after the last line.
onComplete() => void—Called each time the session finishes.
bodyClassNamestring"h-72"Classes for the scrollable body; set the height here.
labelstring"Terminal"Accessible name of the terminal region.

Accessibility

  • The full transcript is always rendered as visually hidden text, so search engines index it and screen readers read it in one go instead of character by character.
  • The animated copy is aria-hidden and nothing is announced while typing (no aria-live chatter).
  • The body is a keyboard-focusable scroll region inside a labelled region landmark; auto-scroll stops following if you scroll up.
  • With prefers-reduced-motion the finished session appears at once and the cursor stops blinking. The cursor blinks at about 1 Hz.
  • Typing pauses while the window is off-screen or the tab is hidden, and every timer is cleared on unmount.