Svelte · Junior · Question 67 of 76

How do you make a checkbox group bound to an array?

<script>
  let toppings = $state([]);
</script>

<input type="checkbox" value="cheese" bind:group={toppings} />
<input type="checkbox" value="ham" bind:group={toppings} />

Explanation

For radio buttons bind:group holds a single value instead of an array.

Further reading

Problem with a question

Svelte · Junior · question 67

Test yourself

Take the Svelte · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz