Terminal
A terminal window for scripted CLI sessions, static by default with optional seeded typewriter playback and a scrubber.
import { Terminal } from '@uthereal/ui/terminal'Terminal playground
Overview
Terminal renders a scripted command-line session inside a standalone window with shell syntax coloring, toned status lines, progress bars, task rows, and a title-bar copy Button.
By default, Terminal renders statically (animated={false}) so readers can inspect and copy commands immediately with zero timer overhead. Set animated to play the session back with a deterministic human typing cadence, streamed output, braille spinners, and a playback scrubber.
Use Terminal for install instructions, CLI walkthroughs, and launch demos. Use Code for source listings, file diffs, and code-to-code magic moves, and JsonViewer for collapsible JSON trees.
| Mode | Prop | Behavior |
|---|---|---|
| Static | animated={false} | Renders the completed session immediately inside a keyboard-scrollable viewport up to rows with zero timers or playback bar. |
| Animated | animated={true} | Types commands on a seeded cadence, streams output, animates progress bars and spinners, auto-scrolls on a spring, and scrubs. |
Usage
'use client'
import { Terminal } from '@uthereal/ui/terminal'
export function InstallTerminal() {
return (
<Terminal
title="Install"
steps={[
{
command: 'npm install @uthereal/ui',
output: [
{ kind: 'progress', label: 'Fetching packages', duration: 1200 },
{ text: 'Added 12 packages in 1.8s', tone: 'success' },
],
},
{
command: 'npx uthereal init',
output: [
{ kind: 'task', label: 'Writing theme tokens', done: '0.3s' },
'Ready at http://localhost:3000',
],
},
]}
onCopy={(commands) => console.log('Copied:', commands)}
/>
)
}Pass animated to enable typewriter playback with play/pause, replay, and scrubbing. Set copyFormat="transcript" to copy prompts and output together instead of commands only. Your application owns clipboard side effects through onCopy, onCopyResult, and onAction.
Examples
Use <SchemaPlayground /> above to inspect static mode options (title, cwd, symbol, rows, copyFormat, and showFinalPrompt). The example below shows animated playback.
Animated playback
animated plays the session from start to finish on a seeded typing cadence, animating progress bars with a mid-bar stall and resolving braille spinners into completed checks. Readers can pause, replay, drag the scrubber, or jump between commands with arrow keys.
- Command: npm install @uthereal/ui. Fetching packages, complete. Added 12 packages in 1.6s
- Command: npx uthereal init --theme studio. Writing theme tokens, done. Checking peer dependencies, done. Local preview: http://localhost:3000 Workspace ready
Output lines
Each entry in step.output uses one of four serializable shapes:
| Shape | Rendered output |
|---|---|
string | Plain line in secondary ink. An empty string prints a blank line; http(s) URLs style as links. |
{ text, tone?, delay? } | Toned line (default, muted, info, success, warning, danger, accent) with status icon. |
{ kind: 'progress', label, duration?, value? } | Label, progress rail, and tabular percentage (value defaults to 100 in static mode). |
{ kind: 'task', label, done?, duration? } | Braille spinner while running, resolving to a check icon and muted done timing label. |
All timing values (delay, duration, and step.pause) are specified in milliseconds.
API reference
Serializable schema arguments and defaults come directly from terminalConfigSchema.
| Argument | Type / default | Description |
|---|---|---|
animated | booleanDefault: false | Render a static completed terminal by default (false), or animate typing, streamed output, progress bars, spinners, and a playback scrubber (true). |
steps | TerminalStep[]— | Ordered CLI commands and output lines (1 to 20 steps); each output entry can be plain text, toned text with status icons, a progress bar, or a spinner task. |
title | stringDefault: "zsh" | Window title shown in the center of the title bar. |
cwd | stringDefault: "~" | Default working directory shown in prompts until a step sets its own cwd. |
symbol | stringDefault: "$" | Prompt symbol rendered after the working directory. |
showFinalPrompt | booleanDefault: true | Show a trailing prompt after the final step (with a blinking caret in animated mode). |
rows | integerDefault: 11 | Visible terminal rows: max scrollable height in static mode, fixed height with spring auto-scroll in animated mode. |
speed | numberDefault: 1 | Playback pace multiplier in animated mode (0.25 to 4). |
autoPlay | booleanDefault: true | Start playback automatically when animated; set false to hold on the opening prompt until Play or scrubbing. |
paused | booleanDefault: false | Hold playback at its current position in animated mode, easing to rest. |
loop | booleanDefault: true | Clear the screen upward and replay after a brief hold in animated mode. |
copyable | booleanDefault: true | Show a copy button in the title bar. |
copyFormat | TerminalCopyFormatDefault: "commands" | Text copied by the title bar button: commands (one per line) or full transcript. |
copyLabel | string— | Accessible name of the copy button ("Copy commands" or "Copy transcript" by default). |
copiedLabel | stringDefault: "Copied" | Shown and announced after copying succeeds. |
failedLabel | stringDefault: "Failed" | Shown and announced when clipboard access fails. |
copyAction | string— | Host-registered action name sent to onAction after a successful copy. |
label | stringDefault: "Terminal session" | Accessible name of the terminal figure. |
caption | string— | Optional visible caption rendered under the terminal window. |
recipe | studio | softDefault: "studio" | Visual treatment; interaction behavior remains identical. |
theme | TerminalTheme— | Color mode, accent, and tokens including fontFamilyMono, textSize, popupRadius, status colors, and shell syntax colors. |
motion | none | subtle | expressiveDefault: "subtle" | Animation preset; none or system prefers-reduced-motion renders the completed session immediately. |
motionOptions | TerminalMotionOptions— | Line entrance fade and loop-clear timing overrides in milliseconds. |
dir | ltr | rtl— | Reading direction of header chrome, playback controls, and caption; terminal output always reads left to right. |
React integration
| Prop | Purpose |
|---|---|
onCopy(text) | Called with the copied commands or transcript after clipboard writes succeed. |
onCopyResult(copied) | Called after every copy attempt with whether the clipboard accepted the text. |
onAction(action) | Handles copyAction after a successful copy. |
renderCaption() | Renders rich React content inside <figcaption> instead of plain text caption. |
renderIcon(name, context) | Replaces status or playback icons (info, success, warning, danger, task-done, play, pause, replay). |
preset | Application defaults overridden by explicit instance props. |
tokens | --ui-* CSS variables applied after the typed theme. |
ref | Ref to the root <figure> element. |
className, style, native | Forwarded to the root <figure>; style wins over motion and theme tokens. |
Keyboard & accessibility
| Key | Mode | Interaction |
|---|---|---|
Tab | All | Moves focus across the copy button, viewport, or playback bar. |
Arrow keys, Page Up/Down | Static | Scrolls the focused terminal viewport when content exceeds rows. |
Arrow Right, Arrow Up, Page Down | Animated | Jumps the scrubber to the next command step. |
Arrow Left, Arrow Down, Page Up | Animated | Jumps the scrubber to the previous command step. |
Home, End | Animated | Jumps to the start or end of the session. |
Space, k | Animated | Toggles play and pause when the scrubber has focus. |
The root element is a <figure> named by label. In static mode, the terminal screen is exposed directly to assistive technology and text selection. In animated mode, the animated screen is aria-hidden while a visually hidden <ol> exposes the full transcript of every command and output line, and a polite role="status" live region announces manual play, pause, replay, and scrubbing without announcing autoplay loops. Status lines never rely on color alone: info, success, warning, and danger lines carry icons, tasks show a check mark, and progress lines show a percentage. Terminal output always reads left to right inside RTL (dir="rtl") layouts. Under forced-colors: active, borders, rails, carets, thumbs, and focus outlines map to system colors.
Motion and theming
In static mode, Terminal runs no timers or animation frames. In animated mode, one requestAnimationFrame loop derives every typed character, output entrance, progress fill, braille frame, spring scroll offset, and scrubber position from a single session clock, writing directly to the DOM only when values change. Playback pauses automatically off screen (IntersectionObserver) and in hidden tabs (visibilitychange), eases playback rate on a critically damped spring when paused or resumed, and feathers scrolling lines out at the top edge. Under motion="none" or prefers-reduced-motion: reduce, animated mode displays the completed session immediately, stops caret blinking, hides play and replay controls, and keeps keyboard and pointer step jumping active on the scrubber.
theme accepts mode, accent, the core group, surfaceSunken, borderSubtle, borderStrong, fontFamilyMono, popupRadius, iconSize, controlHeight, controlThumb, shadowThumb, info, success, warning, textSize, and shell syntax tokens (syntaxString, syntaxNumber, syntaxFlag, syntaxPath, syntaxEnv). UtherealProvider supplies application-wide defaults.
Composition
In agent compositions, Terminal is a leaf. Register copyAction on the host when used. Transient playback position is not persisted to the host store.
{
"type": "Terminal",
"props": {
"title": "Install",
"steps": [
{
"command": "npm install @uthereal/ui",
"output": [{ "text": "Added 12 packages in 1.2s", "tone": "success" }]
}
]
},
"children": []
}