Docs / Sandbox and code /
Terminal
Terminal output panel: monospace text, ANSI color support, and scroll-to-bottom.
Preview
bash — my-app
~/projects/my-app mainbun installbun install v1.1.21 (b6c9056c)+ @prisma/client@5.16.1+ jose@5.6.3+ next@15.2.0+ react@19.0.0+ typescript@5.5.410:22:41268 packages installed [3.41s]~/projects/my-app mainbun run test✓ src/lib/auth.test.ts (6 tests) 48ms✓ src/lib/db.test.ts (3 tests) 12ms10:22:43 Test Files 2 passed (2)Tests 9 passed (9)Duration 1.23s~/projects/my-app main $
Variants
Success output
bash — my-app
~/projects/my-app mainbun installbun install v1.1.21 (b6c9056c)+ @prisma/client@5.16.1+ jose@5.6.3+ next@15.2.0+ react@19.0.0+ typescript@5.5.410:22:41268 packages installed [3.41s]~/projects/my-app mainbun run test✓ src/lib/auth.test.ts (6 tests) 48ms✓ src/lib/db.test.ts (3 tests) 12ms10:22:43 Test Files 2 passed (2)Tests 9 passed (9)Duration 1.23s~/projects/my-app main $
Error output
bash — my-app
~/projects/my-app feat/authbun run buildCreating an optimized production build ..../src/lib/auth.tsType error: Property 'sub' does not exist on type 'JWTPayload'16 | const { payload } = await jwtVerify(token, SECRET)> 17 | if (!payload.sub) throw new AuthError('Invalid token')| ^18 | return payload10:25:07✖ Build failed in 2.14s
Props
| Prop | Type | Description |
|---|---|---|
| lines* | TerminalLine[] | Output lines. Each carries a kind (stdout, stderr, system, prompt, input) and text. |
| title | string | Label shown in the header bar. Defaults to 'Terminal'. |
| prompt | string | When set, renders an active blinking cursor prompt at the bottom with this cwd. |
| promptValue | string | Decorative text after the prompt cursor. |
| maxHeight | string | Max height of the output area before scrolling. Defaults to '320px'. |
| className | string | Additional class names for the root element. |
* required.
Usage
import { Terminal } from "@/components/sandbox/terminal";
<Terminal
title="bash — my-app"
lines={[
{ kind: "prompt", text: "~/my-app main" },
{ kind: "input", text: "bun run test" },
{ kind: "stdout", text: "✓ 9 tests passed (1.23s)", timestamp: "10:22:43" },
]}
prompt="~/my-app main"
/>