You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/test/runtime/samples/binding-input-checkbox-grou.../main.svelte

18 lines
453 B

<script>
export let selected;
export let values;
</script>
<label>
<input type="checkbox" value="{values[0]}" bind:group={selected} /> {values[0].name}
</label>
<label>
<input type="checkbox" value="{values[1]}" bind:group={selected} /> {values[1].name}
</label>
<label>
<input type="checkbox" value="{values[2]}" bind:group={selected} /> {values[2].name}
</label>
<p>{selected.map( function ( value ) { return value.name; }).join( ', ' ) }</p>