0Pricing
Sveltejs Academy · Lesson

bind:checked for Checkboxes

Bind a boolean variable to a checkbox input's checked state.

Checkbox Binding

Use bind:checked to sync a boolean with a checkbox input.

<input type="checkbox" bind:checked={agreed} />

Reading the State

The bound variable is true when checked, false when not.

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