# Streaming terminal

Follow supplied streaming output in a bounded, readable terminal with pause and resume controls.

Access: pro. Category: Data. Kind: composite.

## When to use

- Use it when a page needs follow supplied streaming output in a bounded, readable terminal with pause and resume controls.
- Choose it when the data structure, labels, and state are supplied by the application and must remain consumer controlled.

## Alternatives

- Choose data-table instead when sortable column controls, native row selection and a scrollable table is the actual interface need, rather than streaming terminal.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install Streaming terminal

```sh
npx shadcn@latest add @tidal-pro/streaming-terminal
```

Stylesheets: `components/ui/tidal.css`, `components/ui/streaming-terminal.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/streaming-terminal.css";
import{TidalStreamingTerminal}from"./components/ui/streaming-terminal";
export default()=><div className="tidal-scope"><TidalStreamingTerminal following={false} lines={[{id:"example",text:"Demo"}]} onFollowingChange={() => {}} status={"error"} title={"Demo"}/></div>;
```

## Structured props

- `TidalStreamingTerminal.following: boolean`: Required following value accepted by this exported component.
- `TidalStreamingTerminal.lines: ReadonlyArray<TidalTerminalLine>`: Required lines value accepted by this exported component.
- `TidalStreamingTerminal.onFollowingChange: (following: boolean) => void`: Callback invoked when the following change interaction is proposed.
- `TidalStreamingTerminal.status: TidalTerminalStatus`: Required status value accepted by this exported component.
- `TidalStreamingTerminal.title: ReactNode`: Required title value accepted by this exported component.
- `TidalStreamingTerminal.actionProps?: Partial<Record<Action, ActionProps>> | undefined` (default {}): Optional action props value accepted by this exported component.
- `TidalStreamingTerminal.disabled?: boolean | undefined` (default false): Optional disabled value accepted by this exported component.
- `TidalStreamingTerminal.headingLevel?: "h2" | "h3" | "h4" | "h5" | undefined` (default "h2"): Optional heading level value accepted by this exported component.
- `TidalStreamingTerminal.labels?: Partial<{ idle: string; running: string; complete: string; error: string; copy: string; clear: string; cancel: string; following: string; resume: string; output: string; empty: string; invalid: string; truncated: (shown: number, total: number) => string; count: (total: number) => string; }> | undefined` (default {}): Optional labels value accepted by this exported component.
- `TidalStreamingTerminal.maxHeight?: number | undefined` (default 380): Optional max height value accepted by this exported component.
- `TidalStreamingTerminal.maxVisibleLines?: number | undefined` (default 300): Optional max visible lines value accepted by this exported component.
- `TidalStreamingTerminal.onCancel?: ((event: MouseEvent<HTMLButtonElement>) => void) | undefined`: Callback invoked when the cancel interaction is proposed.
- `TidalStreamingTerminal.onClear?: ((event: MouseEvent<HTMLButtonElement>) => void) | undefined`: Callback invoked when the clear interaction is proposed.
- `TidalStreamingTerminal.onCopy?: ((text: string, event: MouseEvent<HTMLButtonElement>) => void) | undefined`: Callback invoked when the copy interaction is proposed.
- `TidalStreamingTerminal.viewportProps?: ViewportProps | undefined` (default {}): Optional viewport props value accepted by this exported component.
- `TidalStreamingTerminal.viewportRef?: Ref<HTMLDivElement> | undefined`: Optional viewport ref value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/streaming-terminal.tsx) | [Manifest](https://tidalui.com/examples/streaming-terminal.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
import "./components/ui/tidal.css";

import { useEffect, useState } from "react";

import { TidalStreamingTerminal, type TidalTerminalLine, type TidalTerminalStatus } from "./components/ui/streaming-terminal";

import "./components/ui/streaming-terminal.css";



const tidalExampleStyles = ".tidal-scope .streaming-terminal-demo {\n  width: 100%;\n  max-width: 940px;\n  min-width: 0;\n  display: grid;\n  gap: 16px;\n}\n.streaming-terminal-demo-footer {\n  display: flex;\n  align-items: center;\n  gap: 16px;\n  flex-wrap: wrap;\n}\n.streaming-terminal-demo-footer button {\n  min-height: 44px;\n  padding: 0 16px;\n  border: 1px solid var(--t-border);\n  border-radius: 10px;\n  background: var(--t-surface);\n  color: var(--t-ink);\n  font: 600 12px var(--t-font);\n  cursor: pointer;\n}\n.streaming-terminal-demo-footer button:disabled {\n  opacity: 0.5;\n  cursor: not-allowed;\n}\n.streaming-terminal-demo-footer button:focus-visible {\n  outline: 2px solid var(--t-accent);\n  outline-offset: 3px;\n}\n.streaming-terminal-demo-footer p {\n  color: var(--t-muted);\n  font-size: 11px;\n  line-height: 1.5;\n  margin: 0;\n}";

const sample: readonly TidalTerminalLine[] = [
  { id: "1", timestamp: "00:00", text: "Reading project manifest" },
  { id: "2", timestamp: "00:01", text: "Found 12 routes and 38 components" },
  { id: "3", timestamp: "00:02", text: "Compiling the production bundle" },
  { id: "4", timestamp: "00:03", text: "Checking route definitions" },
  {
    id: "5",
    timestamp: "00:04",
    text: "One image is larger than the sample size target",
    level: "warning",
  },
  { id: "6", timestamp: "00:05", text: "Writing preview files" },
  {
    id: "7",
    timestamp: "00:06",
    text: "Build complete. Preview files are ready.",
    level: "success",
  },
];

export function StreamingTerminalDemo() {
  const [lines, setLines] = useState<readonly TidalTerminalLine[]>(
      sample.slice(0, 3),
    ),
    [status, setStatus] = useState<TidalTerminalStatus>("idle"),
    [following, setFollowing] = useState(true),
    [note, setNote] = useState("Sample output. Replay stays in this preview.");
  useEffect(() => {
    if (status !== "running") return;
    let cursor = 0;
    const timer = setInterval(() => {
      cursor++;
      setLines(sample.slice(0, cursor));
      if (cursor === sample.length) {
        setStatus("complete");
        setNote("Sample replay complete.");
      }
    }, 650);
    return () => clearInterval(timer);
  }, [status]);
  return (
    <div className="streaming-terminal-demo">
      <TidalStreamingTerminal
        title="Build output"
        lines={lines}
        status={status}
        following={following}
        onFollowingChange={setFollowing}
        onCancel={() => {
          setStatus("idle");
          setNote("Sample replay stopped.");
        }}
        onClear={
          status === "running"
            ? undefined
            : () => {
                setLines([]);
                setStatus("idle");
                setNote("Sample output cleared.");
              }
        }
        onCopy={async (text) => {
          try {
            await navigator.clipboard.writeText(text);
            setNote("Sample output copied.");
          } catch {
            setNote("Clipboard access is unavailable.");
          }
        }}
      />
      <div className="streaming-terminal-demo-footer">
        <button
          type="button"
          disabled={status === "running"}
          onClick={() => {
            setLines([]);
            setFollowing(true);
            setStatus("running");
            setNote("Replaying sample output. No command is running.");
          }}
        >
          Replay sample
        </button>
        <p role="status">{note}</p>
      </div>
    </div>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <StreamingTerminalDemo />
    </div>
  );
}

```

## Gotchas

- The host application owns data, validation, persistence, navigation, and service side effects described by this API.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"keyboard":["Tab and Shift+Tab follow the component's native focus order."],"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"Verify focus visibility, text alternatives, contrast, and reduced motion in the final composition."}

Consumer-owned unique log lines, plain text, optional timestamps and info/success/warning/error levels. Required controlled idle/running/complete/error status and following value. The viewer renders the latest maxVisibleLines (default 300, 1–1000) with an explicit truncation notice; accepts at most 5000 supplied lines and 2 million text characters. Following scrolls only the local viewport; manual upward scrolling proposes pause, and Resume following returns to the latest line. Optional Copy receives the entire supplied plain-text transcript, Clear and Cancel are consumer callbacks; Cancel is shown only while running. Caller-first native handlers, disabled state, owned button/log semantics, native root/viewport/action refs with React 19 cleanup, bounded maxHeight 160–720, h2-h5 heading levels, localized labels/counts, text-safe rendering, narrow/RTL layouts and reduced motion are supported. No process, connection, request, execution or persistence occurs. The demo replays explicit sample lines on a local timer and supports copying those sample lines.
