mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-14 18:01:06 +00:00
28 lines
568 B
Svelte
28 lines
568 B
Svelte
<script lang="ts">
|
|
import { Checkbox, Button } from "carbon-components-svelte";
|
|
|
|
export let values = ["Apple", "Banana", "Coconut"];
|
|
export let group = values.slice(0, 2);
|
|
|
|
$: console.log("group changed:", group);
|
|
</script>
|
|
|
|
{#each values as value, index}
|
|
<Checkbox
|
|
bind:group
|
|
labelText={value}
|
|
{value}
|
|
data-testid={`checkbox-${index}`}
|
|
/>
|
|
{/each}
|
|
|
|
<Button
|
|
on:click={() => {
|
|
group = ["Banana"];
|
|
console.log("set to banana");
|
|
}}
|
|
>
|
|
Set to ["Banana"]
|
|
</Button>
|
|
|
|
<span data-testid="selected-values">{JSON.stringify(group)}</span>
|