WebberUI

Animated Terminal

逐行打字模擬的命令列終端機,支援指令逐字輸入、輸出揭示與循環播放。

一個帶 macOS 視窗外觀的終端機,依序把每一行「打」出來:command 逐字輸入並帶提示符,outputcomment 按節奏揭示,最後留下閃爍的待命游標。

載入預覽⋯

Playground

即時調整 props、程式碼片段同步更新——直接試出你要的樣子再複製。

45
500
<AnimatedTerminal />

安裝

npx shadcn@latest add https://webberui.com/r/animated-terminal.json

或在 components.json 設定 registries 後,改用 @webberui/animated-terminal 安裝。

安裝依賴後,從 registry JSON(/r/animated-terminal.jsonfiles[0].content)複製 animated-terminal.tsx 原始碼到你的 components/ui/ 目錄:

npm install motion clsx tailwind-merge

使用

import { AnimatedTerminal } from "@/components/ui/animated-terminal";

<AnimatedTerminal
  title="webberui — zsh"
  lines={[
    { type: "command", text: "npm run build" },
    { type: "output", text: "Build complete in 4.2s", delay: 800 },
  ]}
/>;

每一筆 linestype 可為 "command""output""comment";只有 command 會逐字輸入並顯示提示符,outputcomment 會整行揭示。用 delay 為某一行加上開始前的停頓,模擬編譯或等待。

Props

Prop型別預設值說明
linesTerminalLine[]要依序播放的行
typingSpeednumber45command 逐字輸入速度(毫秒/字)
lineDelaynumber500每行完成後、進入下一行前的停頓(毫秒)
startDelaynumber300整體開始前的延遲(毫秒)
promptstring"$"預設提示符
titlestring"bash"視窗標題列文字
showTrafficLightsbooleantrue顯示 macOS 紅黃綠三顆燈
loopbooleanfalse播完後循環重播
loopDelaynumber2200循環前的停頓(毫秒)

TerminalLine

欄位型別預設值說明
type"command" | "output" | "comment""command"行類型
textstring該行文字內容
promptstring繼承 prompt覆寫此行的提示符(僅 command 有效)
delaynumber0此行開始前的額外停頓(毫秒)

可及性

  • 使用者系統開啟「減少動態效果」時,直接完整渲染所有行,游標不閃爍
  • 三顆視窗燈與游標皆帶 aria-hidden,不干擾螢幕閱讀器

On this page