Skip to content

Commit 4c54d30

Browse files
committed
[MultiSelect] Add example of custom option markup
1 parent fc18db3 commit 4c54d30

File tree

1 file changed

+40
-4
lines changed
  • packages/svelte-ux/src/routes/docs/components/MultiSelect

1 file changed

+40
-4
lines changed

packages/svelte-ux/src/routes/docs/components/MultiSelect/+page.svelte

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
<script lang="ts">
2-
import { mdiDotsVertical, mdiPlus } from '@mdi/js';
3-
4-
import { Button, Drawer, Form, MultiSelect, MultiSelectOption, ToggleButton } from 'svelte-ux';
2+
import { mdiCheck, mdiDotsVertical, mdiPlus } from '@mdi/js';
3+
4+
import {
5+
Button,
6+
Drawer,
7+
Form,
8+
Icon,
9+
MultiSelect,
10+
MultiSelectOption,
11+
ToggleButton,
12+
} from 'svelte-ux';
513
import Preview from '$lib/components/Preview.svelte';
614
715
const options = [
@@ -158,7 +166,7 @@
158166
</div>
159167
</Preview>
160168

161-
<h2>option slot</h2>
169+
<h2>option slot with MultiSelectOption custom actions</h2>
162170

163171
<Preview>
164172
{value.length} selected
@@ -203,6 +211,34 @@
203211
</div>
204212
</Preview>
205213

214+
<h2>option slot with custom markup</h2>
215+
216+
<Preview>
217+
{value.length} selected
218+
<div class="flex flex-col max-h-[360px] overflow-auto">
219+
<MultiSelect {options} {value} on:change={(e) => (value = e.detail.value)}>
220+
<svelte:fragment
221+
slot="option"
222+
let:option
223+
let:label
224+
let:value
225+
let:checked
226+
let:indeterminate
227+
let:onChange
228+
>
229+
<button
230+
class="px-2 py-1 text-surface-content flex gap-1 w-full"
231+
role="option"
232+
on:click={onChange}
233+
>
234+
<Icon data={checked ? mdiCheck : ''} />
235+
<div>{label}</div>
236+
</button>
237+
</svelte:fragment>
238+
</MultiSelect>
239+
</div>
240+
</Preview>
241+
206242
<h2>Form integration</h2>
207243

208244
<Preview>

0 commit comments

Comments
 (0)