Skip to Content
DocsDemo Mode

Demo Mode

Demo mode types commands by itself: great for a hero section that shows off what your terminal can do before anyone touches it.

<Terminal fileStructure={files} demo={{ script: ['ls', 'cat about.txt', 'cd projects', 'tree'], behavior: 'interactive', }} />

Each line is typed character by character, run, and followed by a pause:

Runs the script once, then hands the terminal over to you.

Options

OptionTypeDefaultDescription
script(string | step)[]RequiredThe lines to type, in order
mode"run" | "type-writer""run"Run each line, or type and delete it without running
behavior"freeze" | "interactive" | "loop""freeze"What happens when the script ends
defaultCharDelayMsnumber40Delay between typed characters
defaultAfterLineDelayMsnumber600Pause after each line
loopDelayMsnumber800Pause before starting again (with loop)

When the script ends

behaviorResult
freezeThe terminal stays as it is and can’t be typed in
interactiveThe visitor takes over
loopThe screen clears and the script starts again

Input is disabled while the script is running.

Per-line timing

Use an object instead of a string to change the timing of one line:

demo={{ script: [ 'whoami', { line: 'cat a-very-long-file.txt', charDelayMs: 15 }, { line: 'echo "Read that?"', afterLineDelayMs: 2000 }, ], }}
Step optionDescription
lineThe text to type
charDelayMsOverrides defaultCharDelayMs for this line
afterLineDelayMsOverrides defaultAfterLineDelayMs for this line

Type-writer mode

mode: "type-writer" types each line, waits, then deletes it, without running anything. Use it for rotating taglines:

<Terminal windowChrome="none" prompt="> " demo={{ mode: 'type-writer', behavior: 'loop', script: ['I build web apps.', 'I love open source.', 'I write Rust for fun.'], defaultAfterLineDelayMs: 1500, }} />

Demo lines are real commands: anything that works when typed (pipes, your extra commands, cd) works in a script. The prompt follows along as the script changes directory.

The demo restarts when demo.script changes identity. Define the script outside your component or memoize it, so a re-render doesn’t restart it.

Last updated on