mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
* add `Checkbox` reactive example for `bind:checked` (#967) * update `Checkbox` reactive example for `bind:group` to demo two-way binding * simplify `Tabs` reactive example * add `NumberInput` "No value" example
17 lines
441 B
Svelte
17 lines
441 B
Svelte
<script>
|
|
import { Checkbox, Button } from "carbon-components-svelte";
|
|
|
|
let values = ["Apple", "Banana", "Coconut"];
|
|
let group = values.slice(0, 2);
|
|
</script>
|
|
|
|
{#each values as value}
|
|
<Checkbox bind:group labelText="{value}" value="{value}" />
|
|
{/each}
|
|
|
|
<div style="margin: var(--cds-layout-01) 0">
|
|
<Button on:click="{() => (group = ['Banana'])}">Set to ["Banana"]</Button>
|
|
</div>
|
|
|
|
<strong>Selected:</strong>
|
|
{JSON.stringify(group)}
|