0Pricing
Sveltejs Academy · Lesson

bind:value for Text Inputs

Keep text input values in sync with component variables automatically.

What bind:value Does

The bind:value directive creates a two-way connection between a variable and a form input.

Basic Example

Bind a let variable to a text input. Typing updates the variable; programmatic changes update the field.

<script>
  let name = "";
</script>

<input bind:value={name} />
<p>Hello {name}</p>

All lessons in this course

  1. bind:value for Text Inputs
  2. bind:checked for Checkboxes
  3. bind:group for Radio and Checkbox Groups
  4. bind:this for DOM Element References
← Back to Sveltejs Academy