Form
Declarative form layout — a vertical column of labelled rows where each row hosts an arbitrary widget that renders itself based on whether it currently owns focus.
Form is presentation-only. Apps own the field state (the current value of each text field, checkbox, button, …) and a FocusManager that tracks which row owns focus. Form lays out the labels + widgets and asks each row's render callback to produce its VNode, passing the focused boolean so the widget renders the appropriate visual.
Validation is also app-side: apps decide on submit (typically when a specific button row is activated) whether the field state is valid and what to do next. The errors parameter just controls per-row error messages drawn beneath each row.
given Theme = Theme.dark
val NameId = FocusId("name")
val AgreeId = FocusId("agree")
val SaveId = FocusId("save")
Form.column(
rows = Vector(
Form.Row(NameId, "Name:", focused => widgets.Button(label = nameValue, focused = focused)),
Form.Row(AgreeId, "Agree:", focused => widgets.CheckBox("I accept", agree, focused)),
Form.Row(SaveId, "", focused => widgets.Button("Save", focused))
),
focusManager = model.fm,
at = Coord(2.x, 4.y)
)
Value parameters
- height
-
Cell height the row will occupy. Defaults to
1. - id
-
Stable FocusId for the row — passed to the FocusManager for navigation.
- label
-
Label rendered to the left of the widget. Empty string yields no label cell, just the widget.
- widget
-
Render callback receiving
focused: Booleanand returning the row'sVNode.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Form.type