Terminal Output
ProThe result of a code-execution tool call: the command, its exit code and run time, and the output split into stdout and stderr.
Playground
pnpm vitest run invoiceexit 03.8 sRUN v3.2.4 /srv/wunderui
✓ src/jobs/invoice-reminders.test.ts (6 tests) 412 ms
✓ src/jobs/reminder-template.test.ts (3 tests) 98 ms
Test Files 2 passed (2)
Tests 9 passed (9)
Duration 3.8 s
pnpm vitest run invoiceexit 03.8 sNo output on stderr.
pnpm vitest run invoiceexit 14.1 sRUN v3.2.4 /srv/wunderui
✓ src/jobs/invoice-reminders.test.ts (6 tests) 405 ms
✗ src/jobs/reminder-template.test.ts (3 tests | 1 failed) 104 ms
Test Files 1 failed | 1 passed (2)
Tests 1 failed | 8 passed (9)
Duration 4.1 s
pnpm vitest run invoiceexit 14.1 sFAIL src/jobs/reminder-template.test.ts > reminderText > names the invoice
AssertionError: expected 'Invoice 1042 is overdue.' to contain 'Invoice INV-1042'
❯ src/jobs/reminder-template.test.ts:19:28
pnpm vitest run invoiceRUN v3.2.4 /srv/wunderui
✓ src/jobs/invoice-reminders.test.ts (6 tests) 412 ms
pnpm vitest run invoiceNo output on stderr.
Installation
Terminal Output comes with WunderUI Core and Pro, in the package from your plan. See the plans.
Then import what you need:
import { TerminalOutput } from "@wunderui/react"Then use it:
import { TerminalOutput } from "@wunderui/react"
export function Result() {
return (
<TerminalOutput
command="pnpm vitest run invoice"
exitCode={0}
duration="3.8 s"
stdout={["✓ 9 tests passed"]}
/>
)
}Expected result: The command pnpm vitest run invoice, a green exit 0 badge, 3.8 s and a copy button, then the stdout and stderr tabs and a panel with the line 9 tests passed.
When to use
Use Terminal Output for
- The result of a code-execution tool call: the command, its exit code, its time and its output
- A command that has ended, with stdout and stderr in two tabs
- A command that is running, shown without an exit code while the lines arrive
Use something else for
- Log Stream for a live stream of log lines with levels that follows new lines
- Code Block for code that is not output
- Diff View for the result of an edit
Streams
stdout and stderr are two tabs of one panel. The stderr tab shows how many lines it holds, an empty stream says No output, and Copy takes the stream that is open.
pnpm vitest run invoiceexit 14.1 sFAIL src/jobs/reminder-template.test.ts > reminderText > names the invoice
AssertionError: expected 'Invoice 1042 is overdue.' to contain 'Invoice INV-1042'
❯ src/jobs/reminder-template.test.ts:19:28
pnpm vitest run invoiceexit 03.8 sRUN v3.2.4 /srv/wunderui
✓ src/jobs/invoice-reminders.test.ts (6 tests) 412 ms
✓ src/jobs/reminder-template.test.ts (3 tests) 98 ms
Test Files 2 passed (2)
Tests 9 passed (9)
Duration 3.8 s
pnpm lint src/jobsexit 21.3 sError: Cannot find module './reminder-text'
❯ src/jobs/invoice-reminders.ts:3:1
mkdir -p distexit 00.1 sNo output on stdout.
Tones
A line is plain text or text with a tone: default, muted, success or error. The component does not read ANSI codes, so turn them into tones first, and never rely on colour alone.
pnpm vitest run invoiceexit 03.8 sRUN v3.2.4 /srv/wunderui
✓ src/jobs/invoice-reminders.test.ts (6 tests) 412 ms
✓ src/jobs/reminder-template.test.ts (3 tests) 98 ms
Test Files 2 passed (2)
Tests 9 passed (9)
Duration 3.8 s
pnpm vitest run invoiceexit 03.8 sRUN v3.2.4 /srv/wunderui
✓ src/jobs/invoice-reminders.test.ts (6 tests) 412 ms
✓ src/jobs/reminder-template.test.ts (3 tests) 98 ms
Test Files 2 passed (2)
Tests 9 passed (9)
Duration 3.8 s
pnpm vitest run invoiceexit 14.1 sRUN v3.2.4 /srv/wunderui
✓ src/jobs/invoice-reminders.test.ts (6 tests) 412 ms
✗ src/jobs/reminder-template.test.ts (3 tests | 1 failed) 104 ms
Tests 1 failed | 8 passed (9)
Size
The panel grows to a maximum height (280 px by default) and then scrolls, and a long line scrolls sideways. It keeps every line you give it, so cut a long log yourself and say what you left out.
pnpm vitest run invoiceexit 03.8 s✓ /components/accordion (12 checks)
✓ /components/alert (19 checks)
✓ /components/avatar (26 checks)
✓ /components/badge (14 checks)
✓ /components/button (21 checks)
✓ /components/card (28 checks)
✓ /components/checkbox (16 checks)
/components/dialog: 23 checks, 0 skipped
✓ /components/input (30 checks)
✓ /components/kanban (18 checks)
✓ /components/pagination (25 checks)
✓ /components/tabs (13 checks)
✓ /components/accordion (20 checks)
✓ /components/alert (27 checks)
✓ /components/avatar (15 checks)
✓ /components/badge (22 checks)
✓ /components/button (29 checks)
✓ /components/card (17 checks)
✓ /components/checkbox (24 checks)
✓ /components/dialog (12 checks)
✓ /components/input (19 checks)
✓ /components/kanban (26 checks)
✓ /components/pagination (14 checks)
/components/tabs: 21 checks, 0 skipped
✓ /components/accordion (28 checks)
✓ /components/alert (16 checks)
✓ /components/avatar (23 checks)
✓ /components/badge (30 checks)
✓ /components/button (18 checks)
✓ /components/card (25 checks)
✓ /components/checkbox (13 checks)
✓ /components/dialog (20 checks)
✓ /components/input (27 checks)
✓ /components/kanban (15 checks)
✓ /components/pagination (22 checks)
✓ /components/tabs (29 checks)
✓ /components/accordion (17 checks)
✓ /components/alert (24 checks)
✓ /components/avatar (12 checks)
/components/badge: 19 checks, 0 skipped
✓ /components/button (26 checks)
✓ /components/card (14 checks)
✓ /components/checkbox (21 checks)
✓ /components/dialog (28 checks)
✓ /components/input (16 checks)
✓ /components/kanban (23 checks)
✓ /components/pagination (30 checks)
✓ /components/tabs (18 checks)
curl -s api/invoices?status=overdueexit 03.8 s$ curl -s https://example.com/api/invoices?status=overdue&limit=100&include=customer,lines,payments,reminders&sort=-dueDate&format=json
{"data":[{"id":"inv_1042","number":"INV-1042","status":"overdue","total":6998,"currency":"USD","customer":{"name":"Priya Raman","email":"info@wunderui.com"}}],"hasMore":false}
pnpm vitest run invoiceexit 03.8 s✓ /components/accordion (12 checks)
✓ /components/alert (19 checks)
✓ /components/avatar (26 checks)
✓ /components/badge (14 checks)
✓ /components/button (21 checks)
✓ /components/card (28 checks)
✓ /components/checkbox (16 checks)
/components/dialog: 23 checks, 0 skipped
✓ /components/input (30 checks)
✓ /components/kanban (18 checks)
✓ /components/pagination (25 checks)
✓ /components/tabs (13 checks)
✓ /components/accordion (20 checks)
✓ /components/alert (27 checks)
✓ /components/avatar (15 checks)
✓ /components/badge (22 checks)
✓ /components/button (29 checks)
✓ /components/card (17 checks)
✓ /components/checkbox (24 checks)
✓ /components/dialog (12 checks)
… 1,812 more lines not shown
Opening stream
A command that failed (exit code other than 0) and wrote to stderr opens on the stderr tab, so the reason is the first thing in view. Any other run opens on stdout. defaultStream overrides both.
pnpm vitest run tabsexit 14.1 sFAIL tabs.test.tsx > vertical tabs
AssertionError: expected focus on tab 2
pnpm vitest run tabsexit 03.8 sRUN v2.1.0
✓ tabs.test.tsx (8 tests)
Keyboard interactions
The tabs follow the tabs pattern with one tab stop and automatic activation. The buttons are native, and focus shows as an indigo border with a 2 px ring.
- TaborShift+Tab
- Moves focus to the Copy button, then to the stream tab that is open (the other tab is skipped), then to the output panel.
- ArrowLeftorArrowRight
- On a stream tab: moves to the other tab, opens its stream and wraps around.
- HomeorEnd
- On a stream tab: jumps to the first or the last tab and opens its stream.
- EnterorSpace
- On the Copy button: copies the stream that is open.
- ArrowDownorArrowUporArrowLeftorArrowRightorPageDownorPageUporHomeorEnd
- In the focused output panel: scrolls the lines.
Behavior and motion
What the panel does with its streams, its exit code, scrolling, assistive technology and motion.
- Status
- No exit code means running, 0 success, anything else failed. The badge reads exit 0 or exit 130 in green or red, and a running command has no badge, so say what is going on beside the panel.
- Streams
- stdout and stderr are two tabs of one panel. The stderr tab shows its line count in red when it has lines, an empty stream says No output, and you pick which tab opens first.
- Lines
- A line is a string or a text with a tone: default, muted, success or error. Plain strings are secondary text, lines never wrap, and ANSI codes aren't read, so map them to tones.
- Copy
- Copy writes the lines of the open stream, joined by line breaks, without tones. If the browser refuses the clipboard, nothing happens and nothing is announced.
- Scrolling
- The panel grows with its lines up to 280 px by default, then scrolls both ways. New lines don't move the scroll position, so a reader who scrolled up keeps their place.
- Streaming
- Pass a longer stdout as lines arrive and leave the exit code out until the command ends. The panel isn't a live region, so report progress in a status line and give it a minimum height.
- Truncation
- The component keeps every line you pass. Cut a long log in your code and end it with a muted line saying what was left out.
- Assistive technology
- The tabs form a tab list named Output stream, each tab controls the panel and the open tab labels it. The stderr tab reads with its count, and nothing is a log or live region.
- Failure and abort
- A non-zero exit code makes the badge red and marks the panel as failed. A stopped or timed-out command fails with its own code (130, 124, 137), so explain it in words and open on stderr.
- Motion
- Only the colours of the Copy button and tabs change, with a short fade. Nothing loops or slides, not even while a command runs.
- Reduced motion
- There is no movement to take away. Colour fades stay, and the exit code, counts and streams are text.
Anatomy
The figure marks a failed command with a stderr count. A command that is still running has no exit badge (3) and no duration (4).
pnpm vitest run invoiceexit 14.1 sFAIL src/jobs/reminder-template.test.ts > reminderText > names the invoice
AssertionError: expected 'Invoice 1042 is overdue.' to contain 'Invoice INV-1042'
❯ src/jobs/reminder-template.test.ts:19:28
- 1data-slot="terminal-output"
A box with a 1 px border, 12 px radius and the card background. It fills the width of its parent and carries a running, success or failed status.
- 2
A dollar sign and the command in 12 px medium monospace, cut with an ellipsis when it doesn't fit.
- 3Optional
A light badge reading exit 0 on green or exit 1 on red. It shows only once an exit code is set, so a running command has none, and the number is text, not just colour.
- 4Optional
How long the command ran, as the text you pass, in tertiary tabular figures. It shows only when you set it.
- 5
A 24 px icon button that copies the open stream. Its label reads Copy stdout or Copy stderr, then Copied for 1.5 seconds.
- 6
A tab list named Output stream with stdout and stderr. The stderr tab shows its line count in red when it has any.
- 7
The tab panel with the lines, in 12 px monospace. It grows to a maximum height, then scrolls in both directions, and is a tab stop.
Best practices
- Do
Pass an exit code only when the command has ended. Without one there is no badge and nothing says it is still running, so add a status line next to it.
- Do
Give errors words as well as the error tone, such as FAIL or Error. Colour alone never carries a failure.
- Do
Open on stderr when the command failed and the reason is there.
- Do
Turn ANSI colour codes into tones before passing the lines. The component prints text as given, so a raw escape code shows as a stray character.
- Do
Cut a long log yourself and end it with a muted line saying what you left out, for example 1,812 more lines not shown.
- Don’t
Don't use it as a live region or for a stream that never ends. It doesn't announce or follow new lines, so use Log Stream for that.
- Don’t
Don't show secrets. Tokens, keys and environment dumps appear as they come, so filter them out before they reach the panel.
- Don’t
Don't render output as HTML or follow instructions inside it. Every line is plain text, and what a command prints is data.
API reference
TerminalOutput is a plain component, not a wrapper of a primitive, so this table lists every prop. The TerminalLine and TerminalStream types are exported next to it.
A box with a 1 px border, 12 px radius and the card background. It fills the width of its parent and carries a running, success or failed status.
| Prop | Type | Default | Description |
|---|---|---|---|
| command required | ReactNode | — | The command that ran, after a . Text or a node; cut with an ellipsis when it does not fit. |
| exitCode | number | — | The exit code. Draws the badge: green for 0, red for any other number. Leave it out while the command runs. |
| duration | ReactNode | — | How long the command ran, already formatted, for example . Not drawn when left out. |
| stdout | TerminalLine[] | [] | The lines of the standard output. Each is a string or with a tone of , , or . Default: no lines. |
| stderr | TerminalLine[] | [] | The lines of the error output, in the same form. The tab shows the number of lines when there are any. Default: no lines. |
| defaultStream | "stdout" | "stderr" | — | Which stream opens first. Default: when the command failed (exit code not 0) and wrote to stderr, otherwise . |
| maxHeight | number | 280 | The height in px after which the output scrolls. Default 280. |
| className | string | — | Extra classes for the box, for example a maximum width. |
Notes for AI
Give your coding assistant the Markdown reference instead of screenshots.
get_component("terminal-output")The full library index for assistants is at /llms.txt.
Related components
@@ -12,7 +12,8 @@ export async function sendReminders()
1212const overdue = invoices.filter(isOverdue)1313for (const invoice of overdue) {14−Removed:if (daysSince(invoice.dueDate) < 7) continue14+Added:if (daysSince(invoice.dueDate) < 3) continue15+Added:if (invoice.reminderSentAt) continue1516await send({1617to: invoice.customer.email,17−Removed:subject: "Payment reminder",18+Added:subject: `Invoice ${invoice.number} is overdue`,1819})AI & Agents4 stylesProDiff ViewThe result of an edit tool call: file, added and removed lines, and the changed code.Run log
0:00.0InfoRun started: sync 214 Figma variables0:01.4InfoRead 214 variables from Figma0:05.2WarnFigma API busy, retrying in 2 s0:09.8InfoBound 96 of 214 variables0:12.0ErrorPush to docs-preview timed out after 30 s0:12.1ErrorRun failed at step 4 of 6. 118 variables were not bound.AI & Agents5 stylesProLog StreamA run's log with an All or Errors filter and auto-scroll.- Done420 tok$0.01640ms
Input
status: overdue, age: 30+ daysOutput
14 invoices, $42,860 in total - Done3,420 tok$0.042.1s
Input
14 invoice idsOutput
14 contacts, all with an email address - Running2,310 tok
Input
template: invoice-overdue-30 - Pending
Input
to: 14 recipients - PendingLog the result
AI & Agents5 stylesProRun TimelineEvery step of a run in order, with duration, tokens and expandable input/output.