AI Chat Components
Components built for AI chat scenarios: message bubbles, reasoning chains, tool calls, agent status, plans and test results, cited sources, code diffs, terminals, file trees, artifacts, and more. Each example shows the formatted, highlighted TokUI DSL on the left and the live render on the right; click "Edit" to tweak it instantly.
Reasoning Block think
A collapsible reasoning-process container, closed by [/think]. open expands by default, tt sets the title.
| Prop | Meaning | Example |
|---|---|---|
tt | Title | tt:思考过程 |
open | Expanded by default | open |
Reasoning Chain think-chain / think-step
A step-by-step reasoning container. think-chain sets the overall title; each think-step shows its status, title, and duration.
| Prop | Meaning | Applies to |
|---|---|---|
tt | Overall title | think-chain |
status | Step status (pending/running/done/error) | think-step |
tt | Step title | think-step |
dur | Duration | think-step |
Chat Bubble bubble
A chat message container. role aligns the bubble left/right; model and time appear in the meta row.
| Prop | Meaning | Example |
|---|---|---|
role | Role (user / ai) | role:ai |
model | Model name (AI side) | model:GLM-5.2 |
time | Time text | time:刚刚 |
Toolbar toolbar
A horizontal action bar, usually placed at the top or bottom of a bubble.
| Prop | Meaning | Example |
|---|---|---|
pos | Position | pos:bottom |
align | Alignment | align:right |
Tool Call tool-call
A tool/function-call card showing the name, status, and duration. Status is color-coded: pending/running/done/error/denied.
| Prop | Meaning | Example |
|---|---|---|
name | Tool name | name:web_search |
status | Status | status:done |
duration | Duration | duration:1.2s |
id | Identifier (updatable via upd) | id:tc1 |
Typing Indicator typing
A "typing" three-dot animation, self-closing. text shows text alongside it.
| Prop | Meaning | Example |
|---|---|---|
text | Hint text | text:思考中 |
Quick Reply quick-reply
A one-line quick-reply suggestion, self-closing container. items separates multiple suggestions with |.
| Prop | Meaning | Example |
|---|---|---|
items | Suggestion list (` | `-separated) |
Suggestion Cards suggestions / suggestion
A grid suggestion container; child suggestion nodes show title, description, and icon. cols on suggestions controls the column count.
| Prop | Meaning | Applies to |
|---|---|---|
cols | Column count | suggestions |
clk | Unified click handler | suggestions |
tt | Title | suggestion |
tx | Description | suggestion |
icon | Icon | suggestion |
clk | Click handler | suggestion |
dis | Disabled | suggestion |
Cited Source source
A cited retrieval source / reference, self-closing. Typically listed as numbered [1] [2] citations under a "web search" answer.
| Prop | Meaning | Example |
|---|---|---|
n | Index | n:1 |
tt | Title (quote if it has spaces) | tt:"TokUI 官方文档" |
sn | Snippet excerpt (quote if it has spaces) | sn:"零依赖流式 UI…" |
u / url | Link | u:https://example.com |
tt/snvalues containing spaces must be double-quoted, otherwise they get truncated at the first space.
Code Diff diff
A code-diff container with line numbers and red/green coloring. +/- lines are colored; other lines are context. Raw content mode: inner [ is treated as literal text until [/diff].
| Prop | Meaning | Example |
|---|---|---|
title | Title | title:修复登录校验 |
lang | Language tag | lang:js |
Use
\nfor line breaks: lines starting with+are additions (green),-are deletions (red), and the rest are context lines (gray).
Execution Plan plan / plan-step
A task-plan checklist container. plan sets the title; each plan-step is one step, color-coded by status.
| Prop | Meaning | Applies to |
|---|---|---|
tt | Plan title | plan |
status | Step status (pending/running/done/error/skipped) | plan-step |
tt | Step title | plan-step |
desc | Step description | plan-step |
Agent Status agent
An agent-collaboration card showing name, status, current action, and duration; supports streaming status updates.
| Prop | Meaning | Example |
|---|---|---|
name | Name | name:资料研究员 |
status | Status (idle/running/paused/done/error) | status:running |
action | Current action | action:正在检索文档 |
duration | Duration | duration:8s |
id | Identifier (status updatable via upd) | id:agent1 |
File Tree file-tree / ft-folder / ft-file
A file-tree container with ft-folder children (nestable) and ft-file leaves.
| Prop | Meaning | Applies to |
|---|---|---|
name | Name | both |
open | Expanded by default | ft-folder |
badge | Badge (e.g. M modified / A added / D deleted) | ft-file |
Terminal terminal
A container for terminal commands and output. title is the window title; status is the execution result status. Raw content mode: inner [ is treated as literal text.
| Prop | Meaning | Example |
|---|---|---|
title | Window title | title:bash |
status | Execution status | status:success |
Code Sandbox sandbox
A code-sandbox container with live preview that can execute HTML/CSS/JS. Raw content mode: inner [ is treated as literal text, closed by [/sandbox].
| Prop | Meaning | Example |
|---|---|---|
lang | Language | lang:html |
title | Title | title:实时预览 |
height | Preview height | height:160 |
Test Results test-result / test-case (shorthand case)
A test-run summary container; child test-case nodes (shorthand case, equivalent) list each individual case (pass green / fail red + error / skip gray).
| Prop | Meaning | Applies to | Example |
|---|---|---|---|
pass / fail / skip | Pass / fail / skip counts | test-result | pass:3 fail:1 |
total | Total count | test-result | total:5 |
duration | Total duration | test-result | duration:"2.4s" |
status | Case status (pass/fail/skip) | test-case / case | status:fail |
name | Case name (quote if it has spaces) | test-case / case | name:"parser: basic tags" |
duration | Single-case duration | test-case / case | duration:"0.12s" |
error | Error message (on fail; quote if spaces/brackets) | test-case / case | error:"Expected [/card]" |
name/errorcontaining spaces or[]must be double-quoted, otherwise they get truncated or misparsed.
Git Commit commit
A git-commit info card, self-closing.
| Prop | Meaning | Example |
|---|---|---|
hash | Commit hash (first 7 chars) | hash:abc1234 |
msg | Commit message (quote if it has spaces) | msg:"fix: login validation" |
author | Author | author:sdxiaomu |
branch | Branch | branch:master |
time | Time (quote if it has spaces) | time:"2 hours ago" |
additions / deletions | Added / deleted lines | additions:12 deletions:5 |
Values with spaces (e.g.
msg,time) must be double-quoted, otherwise they get truncated at the first space (msg:fix login bugyields onlyfix).
Message Quote quote
A container that quotes a historical message: role for the source role, tx for the quoted text, msgid for the original message identifier.
| Prop | Meaning | Example |
|---|---|---|
role | Source role | role:user |
tx | Quoted text | tx:之前的提问 |
msgid | Original message ID | msgid:m1 |
Latency Marker latency
A model-response latency / throughput indicator, self-closing. v is the value; t is the type (e.g. ttfb for time-to-first-byte, tok/s for tokens per second).
| Prop | Meaning | Example |
|---|---|---|
v | Value | v:320ms |
t | Type label | t:ttfb |
Video video / Audio audio
Media players; both are self-closing.
| Prop | Meaning | Applies to |
|---|---|---|
s | Media URL | both |
poster | Cover image | video |
tt | Title | audio |
duration | Duration | audio |
Conversation List conversations / conv
A sidebar conversation-history container; child conv nodes are individual conversations.
| Prop | Meaning | Applies to | Example |
|---|---|---|---|
clk | Unified switch handler | conversations | clk:onSwitch |
act | Action endpoint | conversations | act:conv-1 |
tt | Conversation title (quote if spaces) | conv | tt:"How to use SSE" |
time | Time (quote if spaces) | conv | time:"today 14:20" |
active | Currently selected | conv | active |
act | Single-item action | conv | act:conv-2 |
tt/timewith spaces must be double-quoted, otherwise truncated at the first space.
Welcome Screen welcome / welcome-feature (shorthand feature)
A new-session welcome-screen container; child welcome-feature nodes (shorthand feature, self-closing, equivalent) are feature cards.
| Prop | Meaning | Applies to | Example |
|---|---|---|---|
tt | Title | welcome | tt:"Hi, I'm the assistant" |
st | Subtitle | welcome | st:"How can I help?" |
tt | Card title | welcome-feature / feature | tt:Write code |
tx | Card description | welcome-feature / feature | tx:"Generate & debug code" |
i | Icon (code / chart / doc) | welcome-feature / feature | i:chart |
clk | Click handler | welcome-feature / feature | clk:onPick |
[feature tt:x tx:y i:code]is self-closing (recommended);[welcome-feature ...][/welcome-feature]is the container form — equivalent. Cards are attr-driven and render as each tag arrives (true streaming).
Attachments attachments / attach
An attachment-upload / list container; child attach nodes are individual attachment items. The t on attach decides the file-type icon color.
| Prop | Meaning | Applies to |
|---|---|---|
clk | Delete / click handler | attachments |
t | File type (image/pdf/word/excel/ppt/zip/code/video/audio) | attach |
s | File name | attach |
u | Download URL | attach |
size | Size | attach |
clk | Click handler | attach |
Artifact artifact / artifact-code / artifact-preview
A side-preview Artifact container: use artifact-code for the code slot and artifact-preview for the live-preview slot inside.
| Prop | Meaning | Applies to |
|---|---|---|
tt | Title | artifact |
lang | Language | artifact |
pos | Panel position | artifact |
w | Panel width | artifact |
Chat Input chat-input
A chat-input container with a send button. auto enables auto-growing height, rows sets the default row count, and max is the max character count.
| Prop | Meaning | Example |
|---|---|---|
ph | Placeholder | ph:输入消息… |
clk | Send handler | clk:onSend |
dis | Disabled | dis |
auto | Auto-grow height | auto |
rows | Default rows | rows:3 |
max | Max characters | max:2000 |
Message Actions msg-actions
A message-action bar container at the bottom of a bubble; supports copy / regenerate / like-dislike toggles.
| Prop | Meaning | Example |
|---|---|---|
clk | Generic handler | clk:onAct |
copy | Show copy | copy |
regenerate | Show regenerate | regenerate |
like / dislike | Like / dislike | like |
visible | Always visible (default: hover) | visible |
Thumbs thumb
A like / dislike button, self-closing. t decides the variant.
| Prop | Meaning | Example |
|---|---|---|
t | Type (like / dislike) | t:like |
clk | Click handler | clk:onLike |
v | State / value | v:12 |
Comprehensive Example: A Real AI Reply
Combining bubble, reasoning chain, tool call, cited sources, markdown, and an action bar into a realistic AI reply.
Tip: handlers referenced by
clk:/sub:must be pre-registered viaTokUI.registerHandler(name, fn); the DSL itself carries no executable code. For the full prop tables, see sections 5.3–5.4 of the DSL syntax reference.