mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-16 02:41:05 +00:00
docs: Checkbox, Tabs, NumberInput (#1045)
* 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
This commit is contained in:
parent
9e915cf90a
commit
4e3415a4e9
6 changed files with 65 additions and 27 deletions
|
@ -1,15 +1,17 @@
|
|||
<script>
|
||||
import { Checkbox } from "carbon-components-svelte";
|
||||
import { Checkbox, Button } from "carbon-components-svelte";
|
||||
|
||||
let options = ["Apple", "Banana", "Coconut"];
|
||||
let selection = options.slice(0, 2);
|
||||
let values = ["Apple", "Banana", "Coconut"];
|
||||
let group = values.slice(0, 2);
|
||||
</script>
|
||||
|
||||
{#each options as option}
|
||||
<Checkbox bind:group="{selection}" labelText="{option}" value="{option}" />
|
||||
{#each values as value}
|
||||
<Checkbox bind:group labelText="{value}" value="{value}" />
|
||||
{/each}
|
||||
|
||||
<div style="margin: var(--cds-layout-01) 0">
|
||||
Selected options:
|
||||
<strong>{selection.join(", ")}</strong>
|
||||
<Button on:click="{() => (group = ['Banana'])}">Set to ["Banana"]</Button>
|
||||
</div>
|
||||
|
||||
<strong>Selected:</strong>
|
||||
{JSON.stringify(group)}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue