Form Components
Form containers, various input controls and selectors. Each example shows the formatted, highlighted TokUI DSL on the left and the live render on the right; click "Edit" to modify it instantly.
Form Container form
Wraps a group of form controls. On submit, triggers the sub: handler or the native act submission.
| Prop | Meaning | Example |
|---|---|---|
act | Submit URL | act:/api/save |
mtd | Submit method | mtd:post |
sub | Submit handler name | sub:onSubmit |
clk | Generic event handler name | clk:onFormClick |
The handler referenced by
sub:must be pre-registered viaTokUI.registerHandler(name, fn); on abtn, usesub:xxxto trigger form submission.
Input input
Single-line text input, self-closing. l for label, ph for placeholder, t for native type, val for initial value.
| Prop | Meaning | Example |
|---|---|---|
l | Label | l:姓名 |
ph | Placeholder hint | ph:"请输入姓名" |
t | Native input type | t:email |
n | Field name | n:username |
val | Default value | val:Tom |
id | Element ID | id:username |
w | Width | w:240 |
hint | Hint text | hint:6~16 个字符 |
search | Search style | search |
req / dis / ro | Required / Disabled / Read-only | req |
Variants: error / success (validation states), sm / lg (sizes), underline (underline style), pill (rounded).
Password pwd
Password input with show/hide toggle, self-closing. Same props as input, plus toggle to control whether plain text can be revealed.
| Prop | Meaning | Example |
|---|---|---|
l | Label | l:密码 |
ph | Placeholder hint | ph:"至少 6 位" |
toggle | Show/hide toggle button | toggle |
req / dis | Required / Disabled | req |
v | Variant (same as input) | v:error |
Textarea textarea
Multi-line text input container. rows for initial row count, maxlen for max character count, auto for auto-growing height.
| Prop | Meaning | Example |
|---|---|---|
l | Label | l:描述 |
ph | Placeholder hint | ph:"请输入描述" |
rows | Initial rows | rows:4 |
maxrows | Max rows (auto mode) | maxrows:8 |
maxlen | Max character count | maxlen:200 |
auto | Auto-grow height | auto |
tx | Default content | tx:"默认文本" |
req / dis / ro | Required / Disabled / Read-only | req |
Dropdown select / opt
select is a container; opt are child option nodes. multi for multi-select, req for required.
| Prop | Meaning | Applies to |
|---|---|---|
l | Label | select |
ph | Placeholder hint | select |
multi | Multi-select | select |
n | Field name | select |
req | Required | select |
v | Variant | select |
tx | Option text | opt |
v | Option value | opt |
chk | Default selected | opt |
select variants: error / success.
Radio Group radio
radio is a container; opt are child option nodes. Options within the same group are mutually exclusive.
| Prop | Meaning | Applies to |
|---|---|---|
l | Group label | radio |
n | Field name | radio |
v | Variant | radio |
tx | Option text | opt |
v | Option value | opt |
chk | Default selected | opt |
Checkbox checkbox
Self-closing. l for label, chk for default checked.
| Prop | Meaning | Example |
|---|---|---|
l | Label | l:同意条款 |
chk | Default checked | chk |
n | Field name | n:agree |
v | Option value | v:1 |
id | Element ID | id:agree |
dis | Disabled | dis |
Switch switch
Self-closing. chk to turn on, clk for the toggle callback.
| Prop | Meaning | Example |
|---|---|---|
l | Label | l:邮件通知 |
chk | Default on | chk |
dis | Disabled | dis |
clk | Toggle handler name | clk:onToggle |
n | Field name | n:notify |
v | Value | v:1 |
id | Element ID | id:notify |
Variants: sm / lg.
Slider slider
Self-closing. min/max/step for range and step, v for current value.
| Prop | Meaning | Example |
|---|---|---|
l | Label | l:音量 |
min | Minimum value | min:0 |
max | Maximum value | max:100 |
step | Step | step:5 |
v | Current value | v:60 |
dis | Disabled | dis |
clk | Drag callback | clk:onSlide |
n | Field name | n:volume |
id | Element ID | id:volume |
Variants: sm / lg.
Rate rate
Self-closing. max for max star count, v for current rating, clk for the select callback.
| Prop | Meaning | Example |
|---|---|---|
l | Label | l:评分 |
v | Current value | v:4 |
max | Max stars | max:5 |
clk | Select callback | clk:onRate |
dis | Read-only / disabled | dis |
tx | Caption text | tx:很好 |
Number Input numinput
Self-closing. Number input with increment/decrement buttons; min/max/step constrain the range.
| Prop | Meaning | Example |
|---|---|---|
l | Label | l:数量 |
v | Current value | v:1 |
min | Minimum value | min:1 |
max | Maximum value | max:99 |
step | Step | step:1 |
dis | Disabled | dis |
n | Field name | n:qty |
id | Element ID | id:qty |
Button Group btngroup
Container that wraps a set of btns. In form scenarios, commonly used as a multi-button action area (for primary button usage see Basic Components).
| Prop | Meaning | Example |
|---|---|---|
id | Group ID | id:actions |
v | Variant | v:vertical |
Variants: vertical (vertical layout), pill (rounded group).
Picker picker
Container; a richer selection panel than select (with search / multiple columns). multi for multi-select, dis for disabled.
| Prop | Meaning | Example |
|---|---|---|
l | Label | l:城市 |
ph | Placeholder hint | ph:"请选择" |
multi | Multi-select | multi |
dis | Disabled | dis |
n | Field name | n:city |
v | Value | v:bj |
id | Element ID | id:city |
Variants: error / success.
Cascader cascader
Container; a multi-level selector that expands level by level (e.g. province/city/district). clk for the select callback.
| Prop | Meaning | Example |
|---|---|---|
l | Label | l:地区 |
ph | Placeholder hint | ph:"请选择" |
dis | Disabled | dis |
clk | Select callback | clk:onPick |
v | Value | v:"北京-朝阳" |
n | Field name | n:region |
id | Element ID | id:region |
Variants: error / success.
Upload upload
Self-closing. accept restricts file types, multi for multiple files, max for maximum count.
| Prop | Meaning | Example |
|---|---|---|
l | Label | l:附件 |
ph | Placeholder hint | ph:"点击或拖拽上传" |
accept | Allowed types | accept:"image/*" |
multi | Multiple files | multi |
max | Max count | max:5 |
dis | Disabled | dis |
clk | Upload callback | clk:onUpload |
n | Field name | n:file |
id | Element ID | id:file |
Variants: sm / lg.
Date Picker datepicker
Self-closing. fmt for date format, v for default value, clk for the select callback.
| Prop | Meaning | Example |
|---|---|---|
l | Label | l:出生日期 |
ph | Placeholder hint | ph:"请选择日期" |
fmt | Date format | fmt:yyyy-MM-dd |
v | Default value | v:2026-06-20 |
clk | Select callback | clk:onDate |
dis | Disabled | dis |
n | Field name | n:birthday |
id | Element ID | id:birthday |
Time Picker timepicker
Self-closing. fmt for time format, v for default value.
| Prop | Meaning | Example |
|---|---|---|
l | Label | l:开始时间 |
ph | Placeholder hint | ph:"请选择时间" |
fmt | Time format | fmt:HH:mm |
v | Default value | v:09:30 |
clk | Select callback | clk:onTime |
dis | Disabled | dis |
n | Field name | n:time |
id | Element ID | id:time |
Datetime Picker datetimepicker
Self-closing. Combined date + time picker; fmt for custom format.
| Prop | Meaning | Example |
|---|---|---|
l | Label | l:预约时间 |
ph | Placeholder hint | ph:"请选择日期时间" |
fmt | Format | fmt:"yyyy-MM-dd HH:mm" |
v | Default value | v:"2026-06-20 09:30" |
clk | Select callback | clk:onDateTime |
dis | Disabled | dis |
n | Field name | n:dt |
id | Element ID | id:dt |
Transfer transfer
Container; a two-column mutually exclusive multi-select mover. tt/tt2 for the two column titles, clk for the move callback.
| Prop | Meaning | Example |
|---|---|---|
l | Label | l:分配角色 |
tt | Left column title | tt:未选 |
tt2 | Right column title | tt2:已选 |
clk | Move callback | clk:onTransfer |
h | Fixed height (inner scroll) | h:240 / h:40vh |
mh | Max height (overrides default 320px) | mh:200 |
dis | Disabled | dis |
n | Field name | n:roles |
id | Element ID | id:roles |
Variants: sm (max 260px) / lg (max 400px). Default max-height 320px; overflowing lists scroll inside (scrollbar transparent by default, grey semi-transparent on hover).
h fixed height and mh max height examples:
Input Tag input-tag
Press Enter to add a tag, click a tag's × to remove it. tags for initial tags, max for maximum count. Self-closing when tags is present; otherwise close with [/input-tag].
| Prop | Meaning | Example |
|---|---|---|
l | Label | l:标签 |
ph | Placeholder hint | ph:"输入后回车添加" |
n | Field name | n:tags |
max | Max count | max:8 |
tags | Initial tags (comma-separated) | tags:"JS,Python" |
dis | Disabled | dis |
For the full DSL syntax (prop shorthands, variant whitelist, streaming render constraints, etc.), see DSL Syntax.