Basics · Bindings
Two-way bind:value
A text <input> owns its own edit buffer — the cursor, the text, the view
offset. To connect that buffer to a signal, use bind:value. It is
two-way: the control writes the signal as the user types, and an external
write to the signal updates the rendered control.
bind:value expects a *sumi.Signal[string]; a type mismatch is a plain Go
compile error. In the starting app the input isn’t bound, so the preview
line below it never updates.
Under the hood bind:value is sugar for wiring the input’s input event to
a handler that mirrors the value. If you need to transform or validate
instead of just mirroring, drop to that event yourself with
oninput={...} and read evt.Data["value"].(string). Use one or the
other: declaring bind:value and oninput on the same input is a
generation error.
Your turn
Bind the input to the draft signal:
<input type="text" bind:value={draft} />
Press Run, click into the input, and type — the preview line tracks every keystroke.