Bind
Use the .bind() method to create a two-way connection between a state property
and a form element. When the state changes, the input updates. When the user types,
the state updates — no event listener boilerplate required.
The selector targets an element in your rendered output, just like .on() — scoped
to your component so there are no conflicts with the rest of the page. The second
argument is the name of the state property to sync with.
.bind() works with any standard form element — input, select, textarea.
Ilha infers the correct value property automatically: value for text and number
inputs, checked for checkboxes.
Because binding is just another builder method, it composes naturally with .on(),
.derived(), and .render(). In the example above, the input and the button both
control the same count state — either can update it, and both stay in sync.
Similar concepts
- React: controlled inputs with
onChange+value - Vue:
v-model - Svelte:
bind:value