Skip to content

Data Display Components

Structured-data components for tables, description lists, pagination, breadcrumbs, dropdowns, calendars, watermarks, avatars, and live updates. Each example shows the formatted, highlighted TokUI DSL on the left and a live render on the right; click "Edit" to modify it in place.

Table table / thead / tbody / tr

The most common data-display combination: the table container is the shell, thead defines the header via cols, tbody holds the rows, and tr is self-closing with comma-separated cells.

PropMeaningApplies toExample
stripeZebra striping (boolean)tablestripe
capTable captiontablecap:用户列表
vVarianttablev:bordered
colsHeader column definitions (comma-separated; quote if it contains , or CJK)theadcols:"姓名,年龄"
csColumn span (leading cell, legacy; prefer cell suffix =cN)trcs:2
nColumn title (only for tcol children)tcoln:名称

Special thead cols placeholders:

  • chk — renders a header checkbox in that column; corresponding row cells auto-render inline checkboxes.
  • # — index column; row cells auto-render 1/2/3... with no need to fill them in.
  • Plain text — used directly as the column title.

tr cell separator: Cells are separated by commas. smartSplit preserves quoted substrings, so wrap an entire cell in double quotes if it contains ,.

1[table stripe]
2 [thead cols:"姓名,年龄,城市,状态"]
3 [tbody]
4 [tr 张三,25,北京,在职]
5 [tr 李四,30,上海,休假]
6 [tr 王五,28,深圳,在职]
7 [/tbody]
8[/table]
Loading TokUI…
TokUI DSL · code ↔ render

Table Variants

v:bordered (full borders), v:compact (tight row height, good for dense data), and stripe (zebra striping) can be combined.

1[table v:"bordered,compact"]
2 [thead cols:"ID,名称,价格,库存"]
3 [tbody]
4 [tr 1,商品A,¥99,200]
5 [tr 2,商品B,¥199,50]
6 [tr 3,商品C,¥299,0]
7 [/tbody]
8[/table]
Loading TokUI…
TokUI DSL · code ↔ render

Checkbox Column

Declare a checkbox column with the chk placeholder in thead cols; leave the corresponding row cell empty or fill it with # to auto-render an inline checkbox.

1[table bordered]
2 [thead cols:"chk,任务,负责人,进度"]
3 [tbody]
4 [tr #,设计登录页,张三,80%]
5 [tr #,开发接口,李四,100%]
6 [tr #,联调测试,王五,30%]
7 [/tbody]
8[/table]
Loading TokUI…
TokUI DSL · code ↔ render

Cell Merging

Append a cell suffix =cN / =rN to merge horizontally (colspan) / vertically (rowspan) — supported in both header and body. The browser's native table layout tracks column positions automatically: a column occupied by a rowspan from above is simply omitted on the next row — no ,,, empty placeholders needed.

SuffixMeaningExample
=cNspan N columnsTotal=c4
=rNspan N rowsRegion=r4
=cNrMboth, c/r order irrelevantval=c2r2

Strict trailing regex — only matches =c<digit> / =r<digit>; values like formula=x=2 or ver=v2 are preserved verbatim.

1[table bordered]
2 [thead cols:"大区=r2,客户,金额/r"]
3 [tbody]
4 [tr 华北区=r2,字节,¥1280]
5 [tr 星辰,¥960]
6 [tr 华东区,云图,¥2100]
7 [/tbody]
8[/table]
Loading TokUI…
TokUI DSL · code ↔ render

Above, 大区=r2 makes 「华北区」 span 2 rows; the second row omits that column (browser reserves the slot). 金额/r also declares that column right-aligned.

Column Alignment & Color

Each thead cols entry may append /align and /color after the column name:

SuffixValuesExample
/alignc center / r right / l left单价/r, 数量/c
/colorprimary / success / warning / danger / info金额/r/danger

Alignment / color propagate by column position to the body (the renderer tracks rowspan offsets, so shifted rows and component cells align correctly). Full col-spec order: name[=cN[rM]][/align][/color], e.g. 金额/r/danger (right + red). Single-segment suffix is also valid — 金额/danger (color only, no align) and 金额/r (align only): the lone segment is matched against the align table first, then the color table.

1[table stripe bordered]
2 [thead cols:"商品,数量/c/primary,单价/r/warning,金额/r/danger"]
3 [tbody]
4 [tr 键盘,5,¥128,¥640]
5 [tr 鼠标,8,¥45,¥360]
6 [tr 显示器,3,¥999,¥2997]
7 [/tbody]
8[/table]
Loading TokUI…
TokUI DSL · code ↔ render

Per-cell Alignment / Color (overrides column)

thead cols sets whole-column alignment/color. When a single cell in a single row needs its own style (e.g. a refund row's amount red while other rows in the same column are not), append the same /align /color to the cell value — it overrides only that cell and leaves other rows untouched:

FormMeaning
"-¥58.00/danger"this cell only: danger color (no align)
"x/r"this cell only: right-aligned
"-¥58.00/r/danger"this cell: right + red
"合计=c4/r/danger"combined with span: span 4 cols + right + red

The cell-level suffix overrides the column-level: where a cell specifies a value, the column-level align/color gives way.

1[table stripe bordered]
2 [thead cols:"菜品,数量,金额/r"]
3 [tbody]
4 [tr 酸汤肥牛,1,¥58.00]
5 [tr 牛肉面,2,¥36.00]
6 [tr 酸汤肥牛(已退),-1,"-¥58.00/danger"]
7 [tr 合计=c2,"¥36.00" v:total]
8 [/tbody]
9[/table]
Loading TokUI…
TokUI DSL · code ↔ render

⚠️ Slashed values (api/v2, 2026/07/04, v1.2.3) are not mis-stripped because their trailing segment isn't in the align/color vocabulary; but if a value happens to end with /c /r /l /danger etc. (e.g. path/r), it will be treated as a suffix — add a trailing space or reorder columns to avoid.

Total Row v:total

Adding the v:total variant to a tr makes it a total row: whole row bold, the leading (summary) cell right-aligned, the trailing (amount) cell bold + centered + --danger colored. Often combined with 汇总=cN to span the whole row.

1[table stripe bordered]
2 [thead cols:"商品,数量/c,单价/r,金额/r"]
3 [tbody]
4 [tr 键盘,5,¥128,¥640]
5 [tr 鼠标,8,¥45,¥360]
6 [tr 汇总=c3,"¥1,000" v:total]
7 [/tbody]
8[/table]
Loading TokUI…
TokUI DSL · code ↔ render

Multi-row Header

Separate thead cols rows with ; (thead stays a single self-closing tag — no container mode). Group columns span with =cN, leaf columns span down with =rN; chk/# special columns only take effect on the last row.

1[table stripe bordered]
2 [thead cols:"基本信息=c2,金额=r2,操作=r2;姓名,年龄"]
3 [tbody]
4 [tr 张三,28,"¥12,800",查看]
5 [tr 李四,32,"¥9,600",编辑]
6 [/tbody]
7[/table]
Loading TokUI…
TokUI DSL · code ↔ render

Above, 「基本信息」 spans the 姓名/年龄 columns, while 「金额」/「操作」 span both header rows; the second header row lists only the 姓名/年龄 leaves, and each body row has 4 cells for the 4 leaf columns.

legacy cs:N: the old tr cs:N only merges the leading cell horizontally and requires ,,, empty placeholders (e.g. [tr cs:3 "前端组"]). Prefer =cN[rM] for new code (any cell, no placeholders). cs:N is still supported.

Parser constraint for tr containing spaces: The parser splits tokens on spaces. If a row has inline attributes (tag:, btn:, progress; note =cN/=rN are cell suffixes and v:total is a row variant — neither triggers this) or a cell value containing spaces, the entire row content must be wrapped in double quotes — e.g. [tr "任务 A,进度 80%,<...>"] — otherwise anything after the space is misparsed as an attribute. See the DSL syntax guide.

Action Column (inline button shorthand)

A cell starting with btn: is recognized as an action column; | separates multiple buttons (clk: still points to a pre-registered handler):

SyntaxDescription
btn:文本 clk:Htext button
btn:文本 v:danger clk:Hcolored (primary/danger/warning/success/info)
btn:文本 icon:view clk:HSVG icon + text
btn: i:🔍 clk:Hemoji icon
btn: icon:delete l:删除 v:danger clk:Hicon-only: l: provides tooltip + a11y label

Icon names match Button · Icon Buttons. icon:NAME renders built-in SVG (inherits button color); i:GLYPH renders emoji.

1[table stripe bordered]
2 [thead cols:"姓名,操作/c"]
3 [tbody]
4 [tr 张三,btn: icon:view l:详情 v:primary clk:toast|btn: icon:edit l:编辑 v:warning clk:toast|btn: icon:delete l:删除 v:danger clk:toast]
5 [tr 李四,btn:详情 clk:toast|btn:删除 v:danger clk:toast]
6 [/tbody]
7[/table]
Loading TokUI…
TokUI DSL · code ↔ render

Streaming: the action column is always the last cell — during streaming it shows a skeleton and only renders the buttons once the whole cell arrives (finalize), so there are never half-SVGs or split emoji surrogates.

Column Placeholders via tcol

When thead omits cols, you can declare columns one by one with tcol children (n sets the title), which is handy for dynamically generated columns.

1[table stripe]
2 [thead]
3 [tcol n:月份]
4 [tcol n:销售额]
5 [tcol n:环比]
6 [/thead]
7 [tbody]
8 [tr 1月,120万,+12%]
9 [tr 2月,190万,+18%]
10 [/tbody]
11[/table]
Loading TokUI…
TokUI DSL · code ↔ render

Client-side Sorting / Filtering / Pagination

table supports purely client-side sorting, filtering, and pagination — freely combinable (filter first, then paginate):

PropMeaningExample
sortableClient-side sorting (click a header to toggle asc/desc, number-aware)sortable
filterClient-side filtering (filter row under the header, substring match, multi-column AND, 300ms debounce)filter
paginationClient-side paginationpagination
psPage size (default 10)ps:20
  • Interaction reporting: sorting sort {column, dir}, filtering filter {filters}, page turns page {value: page number} (via on:"sort:h,filter:h2,page:h3" or the unified outlet).
  • Streaming behavior: rows arriving mid-stream are shown/hidden according to the current filter / page; while a sortable ordering is active, new rows append without re-sorting.
1[table stripe sortable filter pagination ps:5]
2 [thead cols:"姓名,年龄,城市,状态"]
3 [tbody]
4 [tr 张三,25,北京,在职]
5 [tr 李四,30,上海,休假]
6 [tr 王五,28,深圳,在职]
7 [tr 赵六,35,北京,在职]
8 [tr 钱七,26,上海,休假]
9 [tr 孙八,33,深圳,在职]
10 [tr 周九,29,北京,休假]
11 [/tbody]
12[/table]
Loading TokUI…
TokUI DSL · code ↔ render

Description List desc / desc-item

Structured key-value display, commonly used on detail pages. desc is the container; its children are desc-item nodes (l for label, tx for value, span for column span). Children of desc may also be written as [item] — inside desc it is rendered as a description item (same name as the [item] in list, but disambiguated by parent).

PropMeaningApplies toExample
colsColumns per row (default 3)desccols:2
stripeZebra striping (boolean)descstripe
borderedBordered (boolean)descbordered
vLayout directiondescv:horizontal
lwLabel width (effective with horizontal)desclw:120px
lLabel textdesc-item / iteml:用户名
txValue textdesc-item / itemtx:张三
spanColumn span (must not exceed cols)desc-item / itemspan:2

desc variants: horizontal / h (label and value side by side; default stacks them vertically).

1[desc cols:2 bordered]
2 [item l:用户名 tx:张三]
3 [item l:角色 tx:管理员]
4 [desc-item l:邮箱 tx:zhangsan@example.com]
5 [desc-item l:注册时间 tx:2026-01-15]
6[/desc]
Loading TokUI…
TokUI DSL · code ↔ render

[item] and [desc-item] are equivalent inside desc and can be mixed. v:horizontal puts the label and value on the same line; combine with lw to unify the label column width:

1[desc cols:1 v:horizontal lw:100px stripe]
2 [desc-item l:姓名 tx:李四]
3 [desc-item l:部门 tx:产品中心]
4 [desc-item l:备注 tx:核心成员 span:1]
5[/desc]
Loading TokUI…
TokUI DSL · code ↔ render

v:horizontal puts the label and value on the same line; combine with lw to unify the label column width:

1[desc cols:1 v:horizontal lw:100px stripe]
2 [desc-item l:姓名 tx:李四]
3 [desc-item l:部门 tx:产品中心]
4 [desc-item l:备注 tx:核心成员 span:1]
5[/desc]
Loading TokUI…
TokUI DSL · code ↔ render

Pagination pagination

Self-closing. page is the current page, total is the total page count, clk is the page-turn handler, and count is the total item count (shown when show-total is set).

PropMeaningExample
pageCurrent pagepage:3
totalTotal pagestotal:10
countTotal itemscount:128
show-totalShow total count (boolean)show-total
sSizes:sm
clkPage-turn handler nameclk:onPage

Variants (size): sm / lg.

1[pagination page:3 total:10 count:128 show-total clk:onPage]
2[pagination page:5 total:8 s:sm]
Loading TokUI…
TokUI DSL · code ↔ render

The page-switch UI is built in: clicking a page number refreshes it immediately and calls the clk handler with { page }. Register the handler in advance via TokUI.registerHandler.

Self-closing. items is a comma-separated list of node labels, sep is a custom separator (default /), and v:arrow switches the glyph to .

PropMeaningExample
itemsNode labels (comma-separated; quote if it contains , or CJK)items:"首页,用户,详情"
sepSeparatorsep:>
vVariantv:arrow
clkClick handler (the last item does not fire)clk:onCrumb

Variant: arrow (arrow style).

1[breadcrumb items:"首页,用户管理,详情" clk:onCrumb]
2[breadcrumb items:"控制台,数据,报表" v:arrow]
Loading TokUI…
TokUI DSL · code ↔ render

dropdown is a container; the trigger text goes in tt or tx, and its dd-item children are the menu entries. Clicking the trigger opens the menu; selecting an item closes it.

PropMeaningApplies toExample
tt / txTrigger button textdropdowntt:更多操作
vTrigger button variantdropdownv:primary
txMenu item textdd-itemtx:编辑
clkClick handler namedd-itemclk:onEdit
disDisabled (boolean)dd-itemdis
vMenu item variantdd-itemv:danger

dd-item variant: danger (red, for destructive actions).

1[dropdown tt:更多操作]
2 [dd-item tx:编辑 clk:onEdit]
3 [dd-item tx:复制 clk:onCopy]
4 [dd-item tx:导出 clk:onExport]
5 [dd-item tx:删除 v:danger clk:onDel]
6 [dd-item tx:已锁定 dis]
7[/dropdown]
Loading TokUI…
TokUI DSL · code ↔ render

Calendar calendar

Self-closing. month sets the year and month (2026-06), marks highlights specific days (comma-separated day numbers), sel selects discrete days, range:"a-b" selects a single range, and ranges:"a-b;c-d" selects multiple ranges.

PropMeaningExample
monthYear and month (defaults to the current month)month:2026-06
ttCustom titlett:6 月排期
marksHighlighted days (comma-separated)marks:"5,12,20"
selDiscrete selected dayssel:"8,15"
rangeSingle rangerange:"10-18"
rangesMultiple ranges (;-separated)ranges:"3-7;20-25"
vVariantv:card

Variants: card (card style), mini (mini size).

1[calendar month:2026-06 marks:"5,12,20" range:"10-18" sel:"8,25" v:card]
Loading TokUI…
TokUI DSL · code ↔ render

Watermark watermark

Container. tx is the watermark text, c the color, gap the tile spacing, ro the rotation in degrees, and font the font size. Children are the protected content.

PropMeaningExample
txWatermark texttx:内部资料
cColorc:rgba(0,0,0,0.15)
gapTile spacing (px)gap:60
roRotation anglero:-30
fontFont sizefont:18
sSize preset (sm/lg)s:lg
1[watermark tx:TokUI c:rgba(0,0,0,0.12) font:18 gap:60]
2 [card tt:受水印保护的卡片]
3 [p 这段内容被水印覆盖,水印以 canvas 平铺生成,不影响内容交互。]
4 [p 适合用于内部资料、防截图泄露等场景。]
5 [/card]
6[/watermark]
Loading TokUI…
TokUI DSL · code ↔ render

Avatar avatar

Self-closing. s is the image URL (image mode); tx is the text fallback (first two characters used). When s is omitted, the background color is auto-assigned by hashing tx.

PropMeaningExample
sImage URLs:https://.../a.png
txText fallback (first 2 chars)tx:张三
sizeSizesize:lg
bgBackground color (effective in text mode)bg:1677ff
fcText colorfc:fff

Sizes: sm / md (default) / lg / xl.

1[avatar s:https://assets.vdata.chat/jboltai/aiimg/logo_60.png size:lg]
2[avatar tx:张三 size:md]
3[avatar tx:李四 size:md bg:1677ff fc:fff]
4[avatar tx:王五 size:sm]
5[avatar tx:产品 size:lg]
Loading TokUI…
TokUI DSL · code ↔ render

Live Update upd

A self-closing directive. id targets an already-rendered component's ID, and the remaining props are the new field values; at render time it looks up the target element and calls its _update method to refresh. This is typically pushed by the backend over SSE to reflect asynchronous state changes (progress, steps, status colors).

PropMeaningExample
idTarget element ID (required)id:demo
vNew valuev:80
statusNew statusstatus:success
tt / txNew title / new texttt:已完成
actNew actionact:restart

Usage: First render a component with an id, then use the upd directive to override its state. The example below first renders progress at 30%, and the following upd updates the same target to 80% and marks it success — so the final state you see after rendering is the updated one. id accepts comma-separated targets for batch updates: [upd id:a,b v:80] (the same props are applied to every matched component).

1[progress id:demo v:30 l:下载中]
2[upd id:demo v:80 status:success]
Loading TokUI…
TokUI DSL · code ↔ render

Delete & insert directives: [del id:x] removes the component with the given id (a missing target is silently skipped; if the target is a container that is still streaming and not yet closed, del warns via console.warn and skips — wait for it to close before sending del); the container directives [ins after:ID] / before:ID / into:ID insert their children after / before / inside the target (into appends to the target's content slot) — children are staged off-document during streaming and moved in one shot when [/ins] closes. See DSL Syntax · Dynamic update.

calendar live update: [upd id:cal v:"8,15"] / [upd id:cal sel:"8,15"] resets the selected days (comma-separated day numbers, full replacement).

upd only takes effect when the target component implements _update (e.g. progress, stat, steps). If the target is not rendered or has no _update method, upd is a silent no-op and renders as an empty text node. For the full prop list, see section 8 of the DSL reference.