Terminal
A fake shell session that types itself.
import
import { Terminal } from '@joshicodes/cock';Session
~/farm
$ bun run count-flock Coop 1 ...... 6 hens Coop 2 ...... 6 hens Rooster ...... on the roof again 12 of 12 accounted for
Behaviour
- Reserves the height of every line up front, so the box does not grow while it types.
- Waits until it scrolls into view unless `startOnView` is false.
- Screen readers get the finished text, not the animation.
API
Read out of the component sources at build time, so it matches the version you installed.
Every component also takes class, merged
through tailwind-merge so your utility wins.
Props of Terminal
| Prop | Type | Default |
|---|---|---|
lines required | TerminalLine[] | — |
title Shown in the bar above the output, e.g. a working directory. | string | — |
prompt | string | '$' |
speed Milliseconds per typed character. | number | 45 |
lineDelay Default pause between lines. | number | 300 |
loop Start over a few seconds after the last line. | boolean | false |
startOnView Wait until the terminal scrolls into view. | boolean | true |
class | string | — |