Input components
Every input component a card can use, with its properties and an example.
Each component is an object with a type and the properties listed for it. Text and number properties may also hold a {{ }} template or a { "$bind": "…" } object; see Data, state and bindings. Every component also accepts the common properties.
button
Runs an action when pressed.
Does not take children.
| Property | Type | Required | Default | What it does |
|---|---|---|---|---|
label | text | yes | Button text. | |
variant | "primary" "secondary" "outline" "ghost" "danger" | "secondary" | Visual weight. | |
size | "sm" "md" "lg" | "md" | Size. | |
icon | icon name | Icon before the label. | ||
full | boolean | Stretch to the full width. | ||
disabledWhen | expression | Expression; the button is disabled while it is true. | ||
onPress | action or list of actions | What happens when pressed. |
{
"type": "button",
"label": "Press me",
"onPress": {
"type": "toast",
"message": "Pressed"
}
}input
A single-line text field.
Does not take children.
| Property | Type | Required | Default | What it does |
|---|---|---|---|---|
bind | state path | yes | State path this input reads and writes, e.g. state.name. | |
label | text | Label above the field. | ||
placeholder | text | Hint shown when empty. | ||
kind | "text" "number" "email" "url" "password" "date" "time" | "text" | What is being typed. | |
onSubmit | action or list of actions | Runs when Enter is pressed. |
{
"type": "input",
"bind": "state.text",
"label": "Label",
"placeholder": "Type here"
}textarea
A multi-line text field.
Does not take children.
| Property | Type | Required | Default | What it does |
|---|---|---|---|---|
bind | state path | yes | State path this input reads and writes, e.g. state.name. | |
label | text | Label above the field. | ||
placeholder | text | Hint shown when empty. | ||
rows | number | 3 | Visible lines. |
{
"type": "textarea",
"bind": "state.note",
"label": "Note"
}select
Pick one from a dropdown.
Does not take children.
| Property | Type | Required | Default | What it does |
|---|---|---|---|---|
bind | state path | yes | State path this input reads and writes, e.g. state.name. | |
label | text | Label above the field. | ||
placeholder | text | Hint shown when empty. | ||
options | list of objects | yes | The choices offered. | |
options[].label | text | yes | Text shown. | |
options[].value | text | yes | Value stored. | |
onChange | action or list of actions | Runs after the choice changes. |
{
"type": "select",
"bind": "state.choice",
"label": "Choose",
"options": [
{
"label": "One",
"value": "one"
},
{
"label": "Two",
"value": "two"
}
]
}radio
Pick one from a visible list.
Does not take children.
| Property | Type | Required | Default | What it does |
|---|---|---|---|---|
bind | state path | yes | State path this input reads and writes, e.g. state.name. | |
label | text | Label above the group. | ||
options | list of objects | yes | The choices offered. | |
options[].label | text | yes | Text shown. | |
options[].value | text | yes | Value stored. | |
onChange | action or list of actions | Runs after the choice changes. |
{
"type": "radio",
"bind": "state.choice",
"options": [
{
"label": "One",
"value": "one"
},
{
"label": "Two",
"value": "two"
}
]
}segmented
Pick one from a compact row of buttons.
Does not take children.
| Property | Type | Required | Default | What it does |
|---|---|---|---|---|
bind | state path | yes | State path this input reads and writes, e.g. state.name. | |
options | list of objects | yes | The choices offered. | |
options[].label | text | yes | Text shown. | |
options[].value | text | yes | Value stored. | |
onChange | action or list of actions | Runs after the choice changes. |
{
"type": "segmented",
"bind": "state.range",
"options": [
{
"label": "Day",
"value": "day"
},
{
"label": "Week",
"value": "week"
}
]
}checkbox
A checkbox with a label.
Does not take children.
| Property | Type | Required | Default | What it does |
|---|---|---|---|---|
bind | state path | yes | State path this input reads and writes, e.g. state.name. | |
label | text | yes | Text beside the box. | |
onChange | action or list of actions | Runs after it is toggled. |
{
"type": "checkbox",
"bind": "state.agree",
"label": "I agree"
}switch
An on/off switch with a label.
Does not take children.
| Property | Type | Required | Default | What it does |
|---|---|---|---|---|
bind | state path | yes | State path this input reads and writes, e.g. state.name. | |
label | text | yes | Text beside the switch. | |
description | text | Second line under the label. | ||
onChange | action or list of actions | Runs after it is toggled. |
{
"type": "switch",
"bind": "state.enabled",
"label": "Enabled"
}slider
Pick a number by dragging.
Does not take children.
| Property | Type | Required | Default | What it does |
|---|---|---|---|---|
bind | state path | yes | State path this input reads and writes, e.g. state.name. | |
label | text | Label above the slider. | ||
min | number | 0 | Lowest value. | |
max | number | 100 | Highest value. | |
step | number | 1 | Increment. | |
showValue | boolean | Show the current value. | ||
onCommit | action or list of actions | Runs when dragging ends. |
{
"type": "slider",
"bind": "state.level",
"label": "Level",
"showValue": true
}