nook
Browse the docs

Components

Terminal

Native

A terminal window for showing commands and what they print.

See the prompt
~/projects/acme
npx nook-ui init✓Wrote nook.json✓Added the theme to app/globals.css npx nook-ui add button cardInstalling 2 components and 1 dependency✓components/ui/button.tsx✓components/ui/card.tsx✗components/ui/chart.tsx exists, skippedDone in 1.8s

Installation

npx nook-ui@latest add terminal

Prompt

Paste this into your AI coding assistant. It adds this exact component, the same way the CLI does, and tells the assistant how to use it.

Short. For assistants that can run commands in your project.

Plain text
Add the Nook "Terminal" component to this project, exactly as Nook ships it.

A terminal window for showing commands and what they print.

Steps
1. Check for `nook.json` in the project root. If it is missing, run `npx nook-ui@latest init` first (React or Next.js with Tailwind CSS v4). It adds the Nook tokens, the theme and `cn()`.
2. Run `npx nook-ui@latest add terminal`. It writes `components/ui/terminal.tsx` together with everything the component needs. Do not write the component from memory.
3. If you cannot run commands, fetch http://localhost:3000/r/terminal.json, write every entry of `files` to the path it names, install the packages in `dependencies`, and repeat for each name in `registryDependencies`.
4. Use it where I ask. Start from this example:

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

export default function TerminalDefault() {
  return (
    <Terminal className="max-w-lg" title="~/projects/acme" copy={"npx nook-ui init\nnpx nook-ui add button card"}>
      <TerminalLine variant="command">npx nook-ui init</TerminalLine>
      <TerminalLine variant="success">Wrote nook.json</TerminalLine>
      <TerminalLine variant="success">Added the theme to app/globals.css</TerminalLine>
      <TerminalLine variant="muted"> </TerminalLine>
      <TerminalLine variant="command">npx nook-ui add button card</TerminalLine>
      <TerminalLine>Installing 2 components and 1 dependency</TerminalLine>
      <TerminalLine variant="success">components/ui/button.tsx</TerminalLine>
      <TerminalLine variant="success">components/ui/card.tsx</TerminalLine>
      <TerminalLine variant="error">components/ui/chart.tsx exists, skipped</TerminalLine>
      <TerminalLine variant="muted">Done in 1.8s</TerminalLine>
    </Terminal>
  );
}
```

API
- `Terminal`: The window.
  - `title` (`string`): Text in the title bar.
  - `copy` (`string`): Adds a copy button that copies this text.
- `TerminalLine`: One line.
  - `variant` (`"command" | "output" | "success" | "error" | "muted"`, default "output"): What kind of line it is.
  - `prompt` (`string`, default "$"): The prompt sign for commands.

Rules
- Colors, radii, shadows and motion come from Nook tokens and classes such as `bg-primary`, `text-muted-foreground`, `border-border`, `rounded-lg` and `h-control`. Never hard-code them.
- Do not restyle or simplify the file. Change how it looks through `className`, its props and the theme.
- It must keep working with the keyboard, in light and dark mode, and in the sharp, soft and bold styles.
- Accessibility: The lines are real text in a `pre`, so they can be selected and read. The region can be focused to scroll long lines. Success and error lines carry a mark, not only a tone.

Done when the component renders like the example in light and dark mode and the project type-checks.

Usage

import { Terminal, TerminalLine } from "@/components/ui/terminal";

export default function TerminalDefault() {
  return (
    <Terminal className="max-w-lg" title="~/projects/acme" copy={"npx nook-ui init\nnpx nook-ui add button card"}>
      <TerminalLine variant="command">npx nook-ui init</TerminalLine>
      <TerminalLine variant="success">Wrote nook.json</TerminalLine>
      <TerminalLine variant="success">Added the theme to app/globals.css</TerminalLine>
      <TerminalLine variant="muted"> </TerminalLine>
      <TerminalLine variant="command">npx nook-ui add button card</TerminalLine>
      <TerminalLine>Installing 2 components and 1 dependency</TerminalLine>
      <TerminalLine variant="success">components/ui/button.tsx</TerminalLine>
      <TerminalLine variant="success">components/ui/card.tsx</TerminalLine>
      <TerminalLine variant="error">components/ui/chart.tsx exists, skipped</TerminalLine>
      <TerminalLine variant="muted">Done in 1.8s</TerminalLine>
    </Terminal>
  );
}

Examples

A failed build

~/projects/acme
pnpm buildCompiling 214 modules✗Type error: Property 'total' does not exist on type 'Cart'.  at lib/cart.ts:42:18✗Build failed in 6.3s

Custom prompt

deploy@prod-1
docker psCONTAINER ID   IMAGE            STATUS3f2a91c0d4e7   acme/web:1.4.0   Up 3 daysa81b60f2c933   redis:7          Up 3 daysdocker logs --tail 1 web✓Listening on port 3000

Install command

Install
npm install nook-ui

Props

Terminal

The window.

PropTypeDefaultDescription
titlestring–Text in the title bar.
copystring–Adds a copy button that copies this text.

TerminalLine

One line.

PropTypeDefaultDescription
variant"command" | "output" | "success" | "error" | "muted""output"What kind of line it is.
promptstring"$"The prompt sign for commands.

Accessibility

The lines are real text in a `pre`, so they can be selected and read. The region can be focused to scroll long lines. Success and error lines carry a mark, not only a tone.

Checked against WCAG 2.1 AA with automated axe tests and keyboard tests on every release.