Skip to content
WunderUI

Terminal Output

Pro

The 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 s

RUN 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

Installation

Terminal Output comes with WunderUI Core and Pro, in the package from your plan. See the plans.

Then import what you need:

tsx
import { TerminalOutput } from "@wunderui/react"

Then use it:

tsx
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 s

FAIL 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

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 s

RUN 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

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)

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 s

FAIL tabs.test.tsx > vertical tabs

AssertionError: expected focus on tab 2

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.

TaborShiftTab
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 s

FAIL 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

  • data-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.

  • A dollar sign and the command in 12 px medium monospace, cut with an ellipsis when it doesn't fit.

  • Optional

    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.

  • Optional

    How long the command ran, as the text you pass, in tertiary tabular figures. It shows only when you set it.

  • A 24 px icon button that copies the open stream. Its label reads Copy stdout or Copy stderr, then Copied for 1.5 seconds.

  • A tab list named Output stream with stdout and stderr. The stderr tab shows its line count in red when it has any.

  • 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.

PropTypeDefaultDescription
command requiredReactNode—The command that ran, after a . Text or a node; cut with an ellipsis when it does not fit.
exitCodenumber—The exit code. Draws the badge: green for 0, red for any other number. Leave it out while the command runs.
durationReactNode—How long the command ran, already formatted, for example . Not drawn when left out.
stdoutTerminalLine[][]The lines of the standard output. Each is a string or with a tone of , , or . Default: no lines.
stderrTerminalLine[][]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 .
maxHeightnumber280The height in px after which the output scrolls. Default 280.
classNamestring—Extra classes for the box, for example a maximum width.

Notes for AI

Give your coding assistant the Markdown reference instead of screenshots.

MCPget_component("terminal-output")
InstallIncluded in Core and Pro

The full library index for assistants is at /llms.txt.