Terminal window
A terminal-style transcript with selectable command lines, output, and text labels for errors.
pnpm dlx shadcn@latest add @haze/terminal-window---
import { Check, Terminal } from "@lucide/astro";
import { cn } from "../../../lib/haze/utils";
type Line = { text: string; kind?: "command" | "output" | "success" | "error" };
interface Props {
label?: string;
prompt?: string;
lines?: Line[];
class?: string;
}
const {
label = "Release check", prompt = "$", class: className,
lines = [
{ text: "pnpm verify", kind: "command" },
{ text: "Checking build output…" },
{ text: "Verification passed", kind: "success" },
],
} = Astro.props;
const classes = {
command: "text-card-foreground",
output: "text-muted-foreground",
success: "text-success",
error: "text-destructive",
};
---
<figure class={cn("min-w-0 overflow-hidden rounded-xl border border-border bg-card text-card-foreground", className)}>
<figcaption class="flex min-w-0 items-center gap-2 border-b border-border min-h-11 bg-muted/40 px-4 py-1.5 text-[0.8125rem]/5 font-medium">
<Terminal aria-hidden="true" class="size-4 shrink-0 text-muted-foreground" />
<span class="min-w-0 wrap-anywhere">{label}</span>
</figcaption>
<ol class="grid min-w-0 gap-1 px-4 py-3.5 font-mono text-[0.8125rem]/5">
{lines.map(({ text, kind = "output" }) => (
<li class={cn("min-w-0 whitespace-pre-wrap wrap-anywhere", classes[kind])}>
{kind === "command" && <><span aria-hidden="true" class="text-muted-foreground">{prompt} </span><span class="sr-only">Command: </span></>}
{kind === "success" && <Check aria-hidden="true" class="mr-1 inline size-3.5 align-text-bottom" />}
{kind === "error" && <span class="font-medium">Error: </span>}
<code>{text}</code>
</li>
))}
</ol>
</figure>When to use
- Documentation shows a sequence of commands and their output
- A developer-facing example needs a compact shell transcript
When not to use
- People primarily need to copy one command. Use snippet.
- The page needs a running terminal with executable input.
Installation
Add the Haze registry to components.json once, then install Terminal window with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.
pnpm dlx shadcn@latest add @haze/terminal-windownpx shadcn@latest add @haze/terminal-windowyarn dlx shadcn@latest add @haze/terminal-windowbunx --bun shadcn@latest add @haze/terminal-windowFirst time? Registry and theme setup
1. Add to components.json:
{
"registries": {
"@haze": "http://localhost:4329/r/{name}.json"
}
}2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| label | string | "Release check" | Visible figure caption. |
| prompt | string | "$" | Decorative prefix for command lines. |
| lines | { text: string; kind?: "command" | "output" | "success" | "error" }[] | – | Transcript lines in order. The default kind is output. |
| class | string | – | Additional classes on the figure. |
Accessibility
- The transcript is ordinary text. Screen readers get command and error labels.
- Use meaningful success and error text alongside the color.
Notes for AI
Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.
Install and use
Install the Haze UI component "Terminal window" with `npx shadcn@latest add @haze/terminal-window`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import TerminalWindow from "@/components/haze/ui/terminal-window.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/terminal-window.md
Customize with real content
Adapt the Haze terminal-window ui for our product. Replace the demo values of these props with our real content: label, prompt, lines, class. Keep the layout, the heading level rules and these accessibility details: The transcript is ordinary text. Screen readers get command and error labels. Use meaningful success and error text alongside the color. Do not add raw color classes; use the Haze tokens.
Choose the right block
Before using terminal-window, check it fits: use it when documentation shows a sequence of commands and their output; a developer-facing example needs a compact shell transcript. Avoid it when people primarily need to copy one command. use snippet.; the page needs a running terminal with executable input.. Alternatives: @haze/snippet, @haze/code-block.
Dependencies
- npm: @lucide/astro
- @haze/utils
- @haze/theme (one-time setup)
Source · Original Haze UI work.