Terminal
A typing terminal and an inline typewriter for rotating headlines.
# add a sign to the landing page $ npx shadcn@latest add @neonkit/neon-sign Checking registry dependencies... Created components/ui/neon-sign.tsx Done. 1 component added. $ npm run dev Ready on http://localhost:3000 in 412ms
Installation
npx shadcn@latest add https://neonkit.heyaadi.com/r/terminal.jsonUsage
import { Terminal, Typewriter } from "@/components/ui/terminal"
<Terminal
title="~/app"
lines={[
{ kind: "input", text: "npm run build" },
{ kind: "success", text: "Compiled in 4.2s" },
]}
/>
<h1>Neon UI for <Typewriter words={["dashboards", "landing pages"]} /></h1>Examples
Typewriter
Rotating words for a headline.
Errors and a custom prompt
Without loop, a Replay button appears in the title bar when the session ends.
API reference
Terminal
Also accepts native div attributes.
| Prop | Type | Default |
|---|---|---|
lines | TerminalLine[]The session, in order. | None |
title | ReactNodeShown in the title bar. | None |
typingSpeed | numberMilliseconds per typed character, with a little human jitter. | 35 |
loop | booleanStart over 3s after the last line. | false |
startOnView | booleanWait until it scrolls into view before typing. | true |
prompt | stringPrinted before every input line. | "$" |
color | NeonColorPrompt and caret color. | inherited |
onDone | () => voidCalled when the last line has printed: once per run, once per pass when looping, and right away under reduced motion. | None |
TerminalLine
| Prop | Type | Default |
|---|---|---|
kind | "input"input is typed after the prompt; the others print in their own color. | None |
text | stringThe line. Long lines wrap at the terminal's edge. | None |
delay | numberMilliseconds to wait before this line. Defaults to a short think before input and a beat after it. | None |
Typewriter
Also accepts native attributes for the element it renders.
| Prop | Type | Default |
|---|---|---|
words | string[]Typed, held, deleted and replaced in turn. | None |
loop | booleanKeep rotating. When false it stops on the last word. | true |
cursor | booleanA lit caret after the word. | true |
typeSpeed | numberMilliseconds per typed character. | 70 |
deleteSpeed | numberMilliseconds per deleted character. | 40 |
pause | numberMilliseconds a finished word stays up. | 1800 |
as | "span"Element to render. | "span" |
color | NeonColorWord and caret color. | inherited |
Accessibility
- The terminal renders the whole transcript once for screen readers, so nothing is announced per character.
- Typewriter gives screen readers all its words as one phrase instead of the one currently on screen.
- Space for every line is reserved up front, so the terminal doesn't grow while it types.
- Under reduced motion the terminal shows the finished session, and Typewriter swaps words without typing them.