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/each-block-keyed-bind-group/main.svelte

22 lines
384 B

<script>
let flavours = [
'Vanilla',
'Strawberry',
'Chocolate',
'Lemon',
'Coconut'
];
let choices = [];
// Put choices first by sorting
$: flavours = flavours.sort((a, b) => choices.includes(b) - choices.includes(a));
</script>
{#each flavours as flavour (flavour)}
<label>
<input type=checkbox bind:group={choices} value={flavour}>
{flavour}
</label>
{/each}