Components · Inputs
Switch
An on/off switch. Bind checked with { "$bindState": "/path" }.
ExamplesLink to this section
Remaining work
- Fix the flaky upload test
- Update the migration guide
Show JSONHide JSON
{
"version": 1,
"root": "page",
"elements": {
"page": {
"type": "Stack",
"props": { "gap": "md" },
"children": ["toggle", "details"]
},
"toggle": {
"type": "Switch",
"props": {
"label": "Show remaining work",
"checked": { "$bindState": "/open" }
}
},
"details": {
"type": "Card",
"props": { "title": "Remaining work" },
"visible": { "$state": "/open" },
"children": ["todo"]
},
"todo": {
"type": "List",
"props": {
"items": ["Fix the flaky upload test", "Update the migration guide"]
}
}
},
"state": { "open": true }
}PropsLink to this section
Generated from the zod schema the server validates with. Unknown props are ignored with a warning. Any prop can also be a dynamic value such as { "$state": "/path" }; it is checked again once it resolves.
| Prop | Type | Limits and defaults |
|---|---|---|
| labelrequired | string | max 200 chars |
| checked | boolean | — |
| description | string | max 400 chars |
RulesLink to this section
- Inputs change only the spec's own state, on the reader's page. Nothing is saved or sent.
Children and eventsLink to this section
Switch is a leaf: it does not show children. Validation warns when a leaf has some; wrap them in a Stack or Card instead.
Events: change. Bind one with on to run a state action; see Actions.