Bind
Use the bind: template syntax in JSX to create a two-way connection between a state signal and a form element. When the state changes, the input updates. When the user types, the state updates — no event listener boilerplate required.
<input bind:value={state.count} />;
The bind: prefix goes on the attribute, and the value is a signal accessor — either a local .state() accessor or an external signal(). Ilha infers the correct value property automatically: value for text and number inputs, checked for checkboxes.
Because binding is declared directly in the template, it lives right next to the element it controls. 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