Krizaka
Documentation

Terminal replay

A terminal session played back: each command typed at the prompt, its output line by line, the screen following the last line — or the whole session at rest, as the server renders it.

WebBêtaMédias

Web uniquement — React, depuis @krizaka/ui/terminal-replay. Bêta : son API peut encore changer à une version mineure.

Quand l’utiliser

  • Show how a command-line tool works from a recording of a real session: install, start, run.
  • A getting-started page where the reader should see the order of the commands and what each one answers.

Quand ne pas l’utiliser

  • For commands the reader copies and runs, with nothing to watch.À la place : Kbd
  • For a video of an application's screens: record the screens, not a terminal.À la place : Video player
  • For output you wrote by hand: replay what the tool really printed, or show none.

Installation

Installer

npm install @krizaka/ui @krizaka/tailwind @krizaka/tokens tailwindcss

Styles

@import "tailwindcss";
@import "@krizaka/tailwind";
@import "@krizaka/ui/tailwind.css";

Importer

import { TerminalReplay } from "@krizaka/ui/terminal-replay";

Exemples

A session

Three commands typed one after the other, their output line by line; it starts when it scrolls into view.

~/projects — zsh
$ mkdir shop && cd shop

$ npm install @krizaka/ui
added 12 packages in 2s
found 0 vulnerabilities

$ npm run dev
▲ Next.js 16
- Local: http://localhost:3000
✓ Ready in 1.4s

At rest

autoPlay={false}: the whole session is shown until the reader presses play — a page that should stay still.

~/projects — zsh
$ node --version && git --version
v22.12.0
git version 2.47.1

$ docker compose version
Docker Compose version v2.31.0

Props

A terminal session played back: commands typed at the prompt, their output line by line — or the whole session at rest.

PropTypeDéfautDescription
labelrequisstring—The accessible name of the screen (“Terminal session: install, start, dev”) — passed translated.
pauseLabelrequisstring—The pause button's words (the replay is running).
playLabelrequisstring—The play button's words (the replay is waiting or paused).
replayLabelrequisstring—The replay button's words (the session is shown whole).
stepsrequisreadonly TerminalStep[]—The session, in order.
autoPlaybooleantruePlays the first time it scrolls into view. false: the session rests whole until the reader presses play.
copiedLabelstring—What the copy button says once the commands are copied (announced politely).
copyLabelstring—The copy button's words: it copies the commands, one per line. Without it, no copy button.
lineDelaynumber70Milliseconds between two output lines.
promptstring$What the prompt shows before each command.
rowsnumber18The screen's height, in lines; longer sessions scroll.
stepDelaynumber900Milliseconds between a command's last line and the next command.
titleReactNode—The window's title, shown in its bar (~/projects — zsh).
typingSpeednumber34Milliseconds per typed character.

Accessibilité

  • The screen is a named region holding the whole transcript for assistive technology; the characters being typed are hidden from it — never read letter by letter.
  • It starts when it scrolls into view and waits while it is off screen; a control pauses it, plays it or replays it (WCAG 2.2.2).
  • Under prefers-reduced-motion, without JavaScript and before it plays, the whole session is shown at rest; the caret does not blink.
  • The copy button says it copied in a polite live region.

Clavier

TouchesAction
TabFocuses the play, pause or replay control, the copy button, then the screen, which scrolls with the arrow keys.

Bonnes pratiques

  • Replay a real session, captured from the tool itself — never an invented output.
  • Keep each step short: a long output is trimmed where it repeats, and says it was trimmed.
  • Name the screen (label) by what it shows; the words of the controls arrive as props, translated.
  • Give the copy button (copyLabel) when the commands are meant to be run.

Générée depuis le code de @krizaka/ui 2.8.0 : son meta.ts, ses exemples et ses types.Modifier cette documentation sur GitHub

Sur cette page