-
-
Notifications
You must be signed in to change notification settings - Fork 280
Expand file tree
/
Copy path_Group.svelte
More file actions
67 lines (63 loc) · 1.24 KB
/
_Group.svelte
File metadata and controls
67 lines (63 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<div>
{#each options as option}
<FormField>
<Checkbox
bind:group={selected}
value={option.name}
disabled={option.disabled}
/>
{#snippet label()}
{option.name}{option.disabled ? ' (disabled)' : ''}
{/snippet}
</FormField>
{/each}
</div>
<div style="margin-top: 1em;">
<Button
onclick={() => {
const idx = selected.findIndex((v) => v === 'Doc');
if (idx > -1) {
selected.splice(idx, 1);
} else {
selected.push('Doc');
}
}}>Toggle Doc Programmatically</Button
>
</div>
<pre class="status">Selected: {selected.join(', ')}</pre>
<script lang="ts">
import Checkbox from '@smui/checkbox';
import FormField from '@smui/form-field';
import Button from '@smui/button';
let options = [
{
name: 'Bashful',
disabled: false,
},
{
name: 'Doc',
disabled: true,
},
{
name: 'Dopey',
disabled: false,
},
{
name: 'Happy',
disabled: false,
},
{
name: 'Sleepy',
disabled: false,
},
{
name: 'Sneezy',
disabled: false,
},
{
name: 'Grumpy',
disabled: false,
},
];
let selected = $state(['Happy', 'Grumpy']);
</script>