Terminable Component Documentation

Simulate terminal interactions in your documentation

Introduction

Wether to show an example of your CLI that is not video, or just to look cool (yes, terminals are cool ! they. are.) Terminable is for you.

It is built using Shadcn/ui components, and you can (only) install it using my custom shadcn/ui registry

Installation

To install the Terminable component, you can use the following command:

npx shadcn@latest add https://DimitriGilbert.github.io/TerMinable/r/terminable.json

Usage

To integrate the Terminable component into your project:

import Terminable from "@/components/ui/Terminable";

Props

The Terminable component accepts the following props:

NameTypeDefaultDescription
commandsCommandEntry[]requiredAn array of command objects to be executed in the terminal.
titleBarVariant"macos" | "windows" | "linux" | "minimal" | "none""macos"Visual style of the terminal title bar.
titlestring | ReactNode-Title displayed in the title bar.
defaultTypingSpeednumber50Default typing speed in ms per character.
defaultTypingRandomnumber0Randomness factor for typing speed (0–100).
defaultOutputSpeednumber30Delay between output lines in ms.
widthstring"w-full max-w-[800px]"Tailwind width classes for the terminal container.
heightstring"min-h-[300px] max-h-[500px]"Tailwind height classes for the terminal body.
termPromptstring | ReactNode"$ "Prompt symbol shown before each command.
startLinestring | ReactNode""Initial content displayed before commands start.
backgroundColorstringCSS varCSS color value for the terminal background. Overrides the internal CSS variable.
promptColorstringCSS varCSS color value for the prompt text. Overrides the internal CSS variable.
outputColorstringCSS varCSS color value for the output text. Overrides the internal CSS variable.
commandDelaynumber1000Default delay between commands in ms.
allowCopybooleantrueWhether completed commands can be clicked to copy.
startbooleantrueStart processing commands automatically on mount.
onError(error: Error) => void-Callback fired when an error occurs during command processing.
onCopySuccess(text: string) => void-Callback fired when a command is successfully copied to clipboard.
onCopyError(error: Error) => void-Callback fired when copying to clipboard fails.

CommandEntry Object Structure

Each command object in the commands array defines a command to be executed in the terminal. Here are the properties you can use:

NameTypeDescription
promptstring | ReactNode | Array<string | ReactNode>The command prompt string or ReactNode to be typed.
outputstring | OutputContent | ReactNode | Array<string | OutputContent | ReactNode>The output of the command. Can be a string, OutputContent object, ReactNode, or an array of these.
typingSpeednumberTyping speed for this command in ms, overriding the default.
typingRandomnumberRandomness factor for typing speed (0–100), overriding the default.
delaynumberDelay before executing this command in ms, overriding the global commandDelay.
outputDelaynumberDelay before displaying the output of this command in ms.
onDone() => voidCallback function executed when the command is finished.
onCopy() => voidCallback function executed when the command text is copied.
onBeforeOutput() => voidCallback function executed before the output is displayed.

OutputContent Object Structure

The OutputContent object allows you to specify complex output scenarios with placeholders and delays.

NameTypeDescription
delaynumberDelay before the content is displayed, in milliseconds.
placeholderstring | ReactNodePlaceholder content to display while waiting for the delay.
contentstring | ReactNodeThe actual content to display after the delay.

CSS Custom Properties

The component uses CSS custom properties for theming. These are defined with Tokyo Night defaults and can be overridden by passing the corresponding props or by setting the CSS variables in your stylesheet.

VariableDefaultPurpose
--terminable-bg#1a1b26Terminal background color
--terminable-prompt#73dacaPrompt text color
--terminable-output#c0caf5Output text color
--terminable-titlebar-bg#24283bTitle bar background
--terminable-border#3b4261Terminal border color
--terminable-title-color#a9b1d6Title text color
--terminable-hover-bg#292e42Command hover background
--terminable-cursor-color#c0caf5Blinking cursor color
--terminable-dot-green#27c93fmacOS title bar green dot
--terminable-dot-yellow#ffbd2emacOS title bar yellow dot
--terminable-dot-red#ff5f56macOS/Linux title bar red dot

Title Bar Variants

The titleBarVariant prop controls the visual style of the title bar. Choose from five options:

macOS

Windows

Linux

Minimal

none

Examples

Explore these examples to understand how to use the Terminable component in different scenarios.

Basic Commands

Delayed Outputs

Multi-line Outputs

Custom Typing Speeds

React Node Content

Callbacks

Custom Colors

Complex Outputs

Complete Workflow