mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-20 20:33:02 +00:00
Enhance Checkbox to use bind:group
This commit is contained in:
parent
a522a55596
commit
ede294d553
6 changed files with 54 additions and 5 deletions
|
@ -712,7 +712,7 @@
|
|||
"name": "value",
|
||||
"kind": "let",
|
||||
"description": "Specify the value of the checkbox",
|
||||
"type": "string",
|
||||
"type": "string | any",
|
||||
"value": "\"\"",
|
||||
"isFunction": false,
|
||||
"isFunctionDeclaration": false,
|
||||
|
@ -730,6 +730,17 @@
|
|||
"constant": false,
|
||||
"reactive": true
|
||||
},
|
||||
{
|
||||
"name": "group",
|
||||
"kind": "let",
|
||||
"description": "Specify the bound group",
|
||||
"type": "any[]",
|
||||
"value": "[]",
|
||||
"isFunction": false,
|
||||
"isFunctionDeclaration": false,
|
||||
"constant": false,
|
||||
"reactive": true
|
||||
},
|
||||
{
|
||||
"name": "indeterminate",
|
||||
"kind": "let",
|
||||
|
|
|
@ -25,4 +25,10 @@
|
|||
|
||||
### Skeleton
|
||||
|
||||
<Checkbox skeleton />
|
||||
<Checkbox skeleton />
|
||||
|
||||
### Multiple
|
||||
|
||||
Bind a selection list to multiple checkboxes.
|
||||
|
||||
<FileSource src="/framed/Checkbox/MultipleCheckboxes" />
|
||||
|
|
15
docs/src/pages/framed/Checkbox/MultipleCheckboxes.svelte
Normal file
15
docs/src/pages/framed/Checkbox/MultipleCheckboxes.svelte
Normal file
|
@ -0,0 +1,15 @@
|
|||
<script>
|
||||
import { Checkbox } from "carbon-components-svelte";
|
||||
|
||||
let options = ["Apple", "Banana", "Coconut"];
|
||||
let selection = options.slice(0, 2);
|
||||
</script>
|
||||
|
||||
{#each options as option}
|
||||
<Checkbox bind:group="{selection}" labelText="{option}" value="{option}" />
|
||||
{/each}
|
||||
|
||||
<div style="margin: var(--cds-layout-01) 0">
|
||||
Selected options:
|
||||
<strong>{selection.join(", ")}</strong>
|
||||
</div>
|
Loading…
Add table
Add a link
Reference in a new issue