Display and feedback
TerminalCodeBlock
Terminal transcript with copyable commands and ANSI-styled output.
Live example
npm install @cofob/design-system-cssadded 1 package in 842msnpm run build -- --mode production✓ 51 pages built
Report: design.cofob.devnpm install @cofob/design-system-cssadded 1 package in 842msnpm run build -- --mode production✓ 51 pages built
Report: design.cofob.devnpm install @cofob/design-system-css added 1 package in 842ms npm run build -- --mode production ✓ 51 pages built
Report: design.cofob.dev Usage
Each example includes the complete adapter-specific parameter reference. Copy it as a starting point, then remove options your use case does not need.
React
import { TerminalCodeBlock } from "@cofob/design-system-react";
/**
* Complete TerminalCodeBlock parameter reference.
* @param entries
* type: readonly { command: string; output?: string }[]
* required
* example: {entries}
* @param label
* type: string | renderable content
* default: —
* example: "Accessible label"
* @param prompt
* type: string
* default: "$"
* example: "$"
* @param copyable
* type: boolean
* default: true
* example: true
* @param copyLabel
* type: string
* default: "Copy command"
* example: "Accessible label"
* @param copiedLabel
* type: string
* default: "Copied"
* example: "Accessible label"
* @param copyErrorLabel
* type: string
* default: "Try again"
* example: "Accessible label"
* @param copyResetAfter
* type: number (milliseconds)
* default: 1800
* example: 1800
* @param outputLabel
* type: string
* default: "Command output"
* example: "Accessible label"
* @param div attributes
* type: native element attributes
* default: —
* example: class / style / aria-* / data-*
*/
export function TerminalCodeBlockExample() {
return (
<TerminalCodeBlock entries={[{ command: "npm run build", output: "\u001b[1;32mBuild complete\u001b[0m" }]} />
);
}Svelte
<script lang="ts">
import { TerminalCodeBlock } from "@cofob/design-system-svelte";
// Complete TerminalCodeBlock parameter reference.
// entries
// type: readonly { command: string; output?: string }[]
// required
// example: {entries}
// label
// type: string | renderable content
// default: —
// example: "Accessible label"
// prompt
// type: string
// default: "$"
// example: "$"
// copyable
// type: boolean
// default: true
// example: true
// copyLabel
// type: string
// default: "Copy command"
// example: "Accessible label"
// copiedLabel
// type: string
// default: "Copied"
// example: "Accessible label"
// copyErrorLabel
// type: string
// default: "Try again"
// example: "Accessible label"
// copyResetAfter
// type: number (milliseconds)
// default: 1800
// example: 1800
// outputLabel
// type: string
// default: "Command output"
// example: "Accessible label"
// div attributes
// type: native element attributes
// default: —
// example: class / style / aria-* / data-*
</script>
<TerminalCodeBlock entries={[{ command: "npm run build", output: "\u001b[1;32mBuild complete\u001b[0m" }]} />HTML
<!--
Complete TerminalCodeBlock parameter reference.
entries
type: readonly { command: string; output?: string }[]
required
example: {entries}
label
type: string | renderable content
default: —
example: "Accessible label"
prompt
type: string
default: "$"
example: "$"
copyable
type: boolean
default: true
example: true
copyLabel
type: string
default: "Copy command"
example: "Accessible label"
copiedLabel
type: string
default: "Copied"
example: "Accessible label"
copyErrorLabel
type: string
default: "Try again"
example: "Accessible label"
copyResetAfter
type: number (milliseconds)
default: 1800
example: 1800
outputLabel
type: string
default: "Command output"
example: "Accessible label"
div attributes
type: native element attributes
default: —
example: class / style / aria-* / data-*
-->
<div class="cf-terminal-code-block"><div data-cf-copy-scope><code data-cf-copy-source>npm run build</code><button data-cf-copy-button>Copy command</button><pre><code><span class="cf-terminal-output__token" data-bold="true" style="--cf-terminal-token-foreground:var(--cf-terminal-foreground-2)">Build complete</span></code></pre></div></div>
<script type="module">
import { initDesignSystem } from "@cofob/design-system-css";
const designSystem = initDesignSystem(document);
window.addEventListener("pagehide", () => designSystem.destroy(), { once: true });
</script>Parameters
Adapter differences are explicit. Native element attributes are forwarded in React and Svelte and can be written directly in HTML.
| Parameter | Type | Default | Adapters | Example | Description |
|---|---|---|---|---|---|
entriesrequired | readonly { command: string; output?: string }[] | required | React · Svelte · HTML | {entries} | Ordered terminal commands with optional automatically parsed ANSI output kept separate from copyable commands. |
label | string | renderable content | — | React · Svelte · HTML | "Accessible label" | Visible or accessible name, depending on the component. |
prompt | string | "$" | React · Svelte · HTML | "$" | Primary instruction content; terminal prompts are visual and excluded from copied command text. |
copyable | boolean | true | React · Svelte · HTML | true | Enables the clipboard action. |
copyLabel | string | "Copy command" | React · Svelte · HTML | "Accessible label" | Initial accessible copy button text. |
copiedLabel | string | "Copied" | React · Svelte · HTML | "Accessible label" | Temporary success label after copying. |
copyErrorLabel | string | "Try again" | React · Svelte · HTML | "Accessible label" | Error label when clipboard access fails. |
copyResetAfter | number (milliseconds) | 1800 | React · Svelte · HTML | 1800 | Delay before the copy action returns to its initial label. |
outputLabel | string | "Command output" | React · Svelte · HTML | "Accessible label" | Accessible name for command output regions. |
div attributes | native element attributes | — | React · Svelte · HTML | class / style / aria-* / data-* | Forwards native class/style, accessibility, event, and data attributes to the root element. |