Nasaq

TypingTerminal

A terminal that types commands and prints their output step by step, for hero sections and docs. Renders the full transcript first, for servers and reduced motion.

PreviewOpen ↗

Code

import { TypingTerminal } from "@fadymondy/nasaq/web";export function Hero() {  return (    <TypingTerminal      title="~/my-shop"      steps={[        { cmd: "npx create-togo-app my-shop", out: ["\u001b[32m✓\u001b[0m Installed 214 packages"] },        { cmd: "cd my-shop && togo dev", out: ["ready on http://localhost:5173"] },      ]}    />  );}

Website · beta

Live examples and controls: TypingTerminal in the lab.

Install

npx shadcn@latest add https://docs.nasaqui.com/r/typing-terminal.json

Shows how a tool is used: it types each command, prints its output line by line, then offers Replay. Output may contain ANSI colours. An endSlot appears at the end for a screenshot of the result or a call to action.

When to use

  • A marketing hero or a docs page that shows an install or a quick start.

When not to use

  • A real, interactive shell: use Terminal.
  • A command people copy: use a code block with a copy button. The animation is decoration.

Import

import { TypingTerminal } from "@fadymondy/nasaq/web";
// inside this monorepo: "@nasaq/web"

Quick start

import { TypingTerminal } from "@fadymondy/nasaq/web";

export function Hero() {
  return (
    <TypingTerminal
      title="~/my-shop"
      steps={[
        { cmd: "npx create-togo-app my-shop", out: ["\u001b[32m✓\u001b[0m Installed 214 packages"] },
        { cmd: "cd my-shop && togo dev", out: ["ready on http://localhost:5173"] },
      ]}
    />
  );
}

Anatomy

TypingTerminal            data-slot="typing-terminal"  dir="ltr"
├─ header                 dots, title, Replay
├─ transcript             sr-only <pre>, the whole session
└─ body                   data-slot="typing-terminal-body"  fixed height
   ├─ rows                aria-hidden: prompt + command, output lines
   └─ end slot            data-slot="typing-terminal-end"

API

div props (except children and title) plus:

PropTypeDefaultDescription
steps{ cmd, out? }[]requiredCommands without the prompt, and the lines they print.
endSlotReactNodeShown when the playback ends.
titleReactNode"Terminal"In the header.
promptstring"❯"
typeMs / lineMsnumber28 / 110Speed per character and per line.
loopbooleanfalseStart again after 4s instead of showing Replay.
heightnumber320Body height in px, so the page does not move.
playbooleantrueSet from an in-view observer to start when scrolled to. false shows the full transcript.
onComplete() => void
labelsTypingTerminalLabels

Accessibility

  • Screen readers get the whole transcript once, as text; the animated rows are hidden from them.
  • With reduced motion (or under automation) the full transcript shows at once.
  • Replay is a real button. The end slot stays reachable.

RTL & i18n

  • The terminal is always left to right, as code is. Labels (title, Replay) are in English and Arabic.

Styling & tokens

  • bg-nq-surface-soft, a hairline border and the mono font. ANSI colours map to the chart tokens via AnsiText.

Do / Don't

  • Do keep it to two or three commands.
  • Don't animate on every scroll. Use play once, or loop for a hero that stays.

Lab

https://docs.nasaqui.com/?path=/docs/components-website-typing-terminal--docs

On this page