Terminal demo
A terminal window with a transcript of commands and their output.
Preview
Commands are typed and output prints line by line once the window scrolls into view. Pause and replay buttons sit in the title bar. The whole transcript is in the page from the start, so screen readers and copy get all of it and the window never changes height. With reduced motion turned on, it renders the plain layout.
npx shadcn@latest add https://example.com/r/hero.json
✔ Checking registry.
✔ Created 1 file:
- components/custom/hero/hero.tsx
pnpm dev
▲ Ready on http://localhost:3000 (sample output)
npx shadcn@latest add https://example.com/r/hero.json
✔ Checking registry.
✔ Created 1 file:
- components/custom/hero/hero.tsx
pnpm dev
▲ Ready on http://localhost:3000 (sample output)
Installation
Run this in a project that already uses shadcn/ui. It adds the component and anything it needs; the motion version also adds the plain one and the motion package.
Usage
import { TerminalDemo } from "@/components/custom/terminal-demo";
<TerminalDemo
label="zsh"
lines={[
{ kind: "command", text: "npx shadcn@latest add https://example.com/r/hero.json" },
{ kind: "output", text: "✔ Created 1 file." },
]}
/>import { TerminalDemoMotion } from "@/components/custom/terminal-demo/terminal-demo-motion";
<TerminalDemoMotion lines={lines} />Props
| Prop | Type | Default | Description |
|---|---|---|---|
| lines* (required) | { kind: "command" | "output"; text: string }[] | – | The transcript, in order. |
| label | string | "Terminal" | Window title; also the terminal's accessible name. |
| prompt | string | "$" | Shown before each command. Not read aloud and not included when copying. |
| ...props | React.ComponentProps<"div"> | – | Any other div attribute (id, aria-*, data-*, ref) goes to the root element. |
| Prop | Type | Default | Description |
|---|---|---|---|
| lines* (required) | { kind: "command" | "output"; text: string }[] | – | The transcript, in order. |
| label | string | "Terminal" | Window title; also the terminal's accessible name. |
| prompt | string | "$" | Shown before each command. Not read aloud and not included when copying. |
| ...props | React.ComponentProps<"div"> | – | Any other div attribute (id, aria-*, data-*, ref) goes to the root element. |
Accessibility
- The transcript is real text in a pre element: selectable, copyable and read in order.
- The prompt and window dots are decorative and hidden from screen readers.
- The motion version follows the visitor's reduced-motion setting and never hides content before it animates.