UI

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

deploy
~/app$npm run build
Compiling TypeScript0.6s
Bundling routes100%
Build ready (42 kB gzipped)
~/app$npx deploy --prod
Uploading edge assets0.4s
Live: https://app.example.com
Deployment verified in 1.9s
~/app$
Loading interactive preview…

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.

ModePropBehavior
Staticanimated={false}Renders the completed session immediately inside a keyboard-scrollable viewport up to rows with zero timers or playback bar.
Animatedanimated={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.

setup
  1. Command: npm install @uthereal/ui. Fetching packages, complete. Added 12 packages in 1.6s
  2. 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:

ShapeRendered output
stringPlain 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.

ArgumentType / defaultDescription
animatedbooleanDefault: falseRender a static completed terminal by default (false), or animate typing, streamed output, progress bars, spinners, and a playback scrubber (true).
stepsTerminalStep[]—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.
titlestringDefault: "zsh"Window title shown in the center of the title bar.
cwdstringDefault: "~"Default working directory shown in prompts until a step sets its own cwd.
symbolstringDefault: "$"Prompt symbol rendered after the working directory.
showFinalPromptbooleanDefault: trueShow a trailing prompt after the final step (with a blinking caret in animated mode).
rowsintegerDefault: 11Visible terminal rows: max scrollable height in static mode, fixed height with spring auto-scroll in animated mode.
speednumberDefault: 1Playback pace multiplier in animated mode (0.25 to 4).
autoPlaybooleanDefault: trueStart playback automatically when animated; set false to hold on the opening prompt until Play or scrubbing.
pausedbooleanDefault: falseHold playback at its current position in animated mode, easing to rest.
loopbooleanDefault: trueClear the screen upward and replay after a brief hold in animated mode.
copyablebooleanDefault: trueShow a copy button in the title bar.
copyFormatTerminalCopyFormatDefault: "commands"Text copied by the title bar button: commands (one per line) or full transcript.
copyLabelstring—Accessible name of the copy button ("Copy commands" or "Copy transcript" by default).
copiedLabelstringDefault: "Copied"Shown and announced after copying succeeds.
failedLabelstringDefault: "Failed"Shown and announced when clipboard access fails.
copyActionstring—Host-registered action name sent to onAction after a successful copy.
labelstringDefault: "Terminal session"Accessible name of the terminal figure.
captionstring—Optional visible caption rendered under the terminal window.
recipestudio | softDefault: "studio"Visual treatment; interaction behavior remains identical.
themeTerminalTheme—Color mode, accent, and tokens including fontFamilyMono, textSize, popupRadius, status colors, and shell syntax colors.
motionnone | subtle | expressiveDefault: "subtle"Animation preset; none or system prefers-reduced-motion renders the completed session immediately.
motionOptionsTerminalMotionOptions—Line entrance fade and loop-clear timing overrides in milliseconds.
dirltr | rtl—Reading direction of header chrome, playback controls, and caption; terminal output always reads left to right.

React integration

PropPurpose
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).
presetApplication defaults overridden by explicit instance props.
tokens--ui-* CSS variables applied after the typed theme.
refRef to the root <figure> element.
className, style, nativeForwarded to the root <figure>; style wins over motion and theme tokens.

Keyboard & accessibility

KeyModeInteraction
TabAllMoves focus across the copy button, viewport, or playback bar.
Arrow keys, Page Up/DownStaticScrolls the focused terminal viewport when content exceeds rows.
Arrow Right, Arrow Up, Page DownAnimatedJumps the scrubber to the next command step.
Arrow Left, Arrow Down, Page UpAnimatedJumps the scrubber to the previous command step.
Home, EndAnimatedJumps to the start or end of the session.
Space, kAnimatedToggles 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": []
}

On this page