Basic Components
The most frequently used display components: headings, text, buttons, tags, callouts, progress, statistics, loaders, Markdown, syntax highlighting, and more. In each example, the left panel shows the formatted and highlighted TokUI DSL, while the right panel renders it live; click "Edit" to modify it on the fly.
Headings h1 ~ h6
Six-level headings, self-closing. tx is the text (optional — you can write the content inline), and v controls alignment and decoration.
| Prop | Meaning | Example |
|---|---|---|
tx | Text content (or write content inline) | [h1 标题] |
v | Variant | v:underline |
Variants: left / center / right (alignment), ribbon, underline, badge / pill.
Paragraph p
Body paragraph, dual-mode (same trap as card's tx self-closing): body text present → leaf self-closing; no body text → container collecting children. v controls alignment and weight.
- Leaf mode
[p text]/[p v:bold text]: text is the body; may hold inline children (a/tag/b/strong/em/mark/spin/sub/sup/code); auto-closes on a block sibling. - Container mode
[p]...[/p]: use when placing block children likebtn/form/card; must close with[/p]. - Body text shaped like
word:value(e.g.Q:/A:) is parsed as an attribute (no-space → body empty; with-space → prefix vanishes) — use a full-width:or drop the colon (see DSL syntax).
Variants: left / center / right (alignment), muted, bold, sm / lg (font size).
Link a
Hyperlink, self-closing. u is the URL, tx is the text, and target controls how it opens.
| Prop | Meaning | Example |
|---|---|---|
u | URL | u:https://example.com |
tx | Text | tx:官网 |
target | Open behavior | target:_blank |
v | Variant | v:underline |
Variants: muted / danger / success / underline.
Divider hr / dv
hr is a plain horizontal rule (self-closing). dv is a divider with text and styling (self-closing).
| Prop | Meaning | Applies to |
|---|---|---|
tx | Divider text | dv |
v | Line style / direction | dv |
bg | Color | dv |
dv variants: dashed / dotted (line style), sm / md / lg (spacing), vert (vertical), plain.
Image img / Gallery imgs
img renders a single image with click-to-zoom lightbox preview. imgs is a container that lays out multiple images in an adaptive grid (up to 3×3).
| Prop | Meaning | Example |
|---|---|---|
s | Image URL | s:https://... |
alt | Alt text | alt:封面 |
w / h | Width / Height | w:120 |
v | Variant | v:avatar |
img variants: avatar, rounded, bordered.
imgs multiple images: pass comma-separated URLs via s, and they are arranged into a 1–9 cell grid automatically.
Button btn / Button Group btngroup
btn is self-closing and is the most commonly used interactive component. btngroup is a container that wraps a set of buttons.
| Prop | Meaning | Example |
|---|---|---|
tx | Text | tx:提交 |
clk | Click handler name | clk:onSave |
sub | Form submit handler name | sub:onSubmit |
dis | Disabled | dis |
w | Width | w:200 |
bg / fc | Background / text color | bg:4f46e5 |
t | Native type | t:reset |
v | Variant (type / size / shape) | v:"primary,pill" |
Type variants: primary / danger / success / warning / ghost. Size / shape variants: sm / lg / pill (rounded) / square (sharp corners) / block (full-width).
Handlers referenced by
clk:/sub:must be pre-registered viaTokUI.registerHandler(name, fn); the DSL itself never carries executable code.
Tag tag
Labels and categorization, self-closing.
| Prop | Meaning | Example |
|---|---|---|
tx | Text | tx:新功能 |
t | Type / color | t:danger |
s | Size | s:sm |
round | Rounded | round |
closable | Closable | closable |
bordered | Outlined | bordered |
Callout callout
Informational prompt with an icon, self-closing.
| Prop | Meaning | Example |
|---|---|---|
t | Type | t:success |
tt | Title | tt:操作成功 |
tx | Body | tx:已保存 |
Types: info / success / warning / error / tip.
Status Dot dot
Status indicator, self-closing.
| Prop | Meaning | Example |
|---|---|---|
t | Status type | t:success |
tx | Text | tx:运行中 |
s | Size | s:lg |
pulse | Pulse animation | pulse |
Badge badge / badge-box
badge is a numeric / dot badge (self-closing) that wraps its children. badge-box is a container that attaches a corner badge to its children.
| Prop | Meaning | Applies to |
|---|---|---|
count | Number (parseInt truncates decimals; use tx for versions/decimals) | both |
dot | Dot | both |
tx | Text badge | both (badge-box also accepts legacy label; tx preferred) |
t | Status color (default/primary/success/warning/error) | both |
overflow | Overflow display (e.g. 99+) | both |
pill | Pill (rounded) | badge |
size | Size (sm/lg) | badge |
title | Hover tooltip | badge |
Two ways to badge a heading (h3 is self-closing; never nest [h3 text [badge]]):
- Inline pill (a label beside the title, e.g. a version/status): wrap
h3+badgeinrow v:inline(flex mode). Must usev:inline— the defaultrowis a 12-col grid that squeezes the heading into wrap. - Corner badge (top-right marker, e.g. unread/dot): wrap
h3inbadge-box.
Progress progress
Self-closing. v is the current value (0–100).
| Prop | Meaning | Example |
|---|---|---|
v | Current value | v:60 |
l | Label | l:下载中 |
t | Shape | t:circle |
stripe | Striped | stripe |
status | Status color | status:success |
Shapes: line (default) / circle (ring) / span (inline).
Statistic stat
Data display card, self-closing.
| Prop | Meaning | Example |
|---|---|---|
tt | Label | tt:今日访问 |
v | Value | v:12345 |
pre / suf | Prefix / suffix | suf:% |
trend | Trend | trend:up |
dec | Decimal places | dec:1 |
anim | Number animation | anim |
Countdown countdown
Self-closing. Provide target as a target timestamp or dur as the countdown duration in seconds.
| Prop | Meaning | Example |
|---|---|---|
target | Target time | target:2026-12-31 |
dur | Duration in seconds | dur:3600 |
fmt | Format | fmt:dd天hh:mm:ss |
tx | End text | tx:已结束 |
Loader spin / Skeleton skeleton / Shimmer shimmer
spin is a loading indicator, skeleton is a skeleton screen, and shimmer is a shimmering placeholder. All are self-closing.
| Prop | Meaning | Applies to |
|---|---|---|
t | Type | all three |
s | Size | spin |
tx | Text | spin |
rows | Number of rows | skeleton / shimmer |
Empty State empty / Result Page result
empty is a no-data placeholder and result is an operation result page. Both are self-closing.
| Prop | Meaning | Applies to |
|---|---|---|
tx | Description | both |
icon | Icon | empty |
t | Type | result |
tt | Title | result |
result types: success / error / warning / info.
Copy copy
One-click copy button, self-closing. id points to the target element to copy, or it copies the tx text.
| Prop | Meaning | Example |
|---|---|---|
id | Target element ID | id:codeBlock |
tx | Button text | tx:复制 |
tt | Success toast | tt:已复制 |
Markdown md
Markdown rendering container. Supports common syntax: headings, lists, blockquotes, code, tables, links, and more.
Code Block code
Syntax-highlighted code container. lang specifies the language; the zero-dependency built-in highlighter covers 11 languages: js / ts / python / java / go / rust / sql / html / css / json / bash.
| Prop | Meaning | Example |
|---|---|---|
lang | Language | lang:js |
tx | Title (file name) | tx:app.js |
Inside code content, newlines are encoded as
\n. See the DSL syntax reference for the full prop table.