Skip to content

Commit

Permalink
[MultiSelect] Add example of custom option markup
Browse files Browse the repository at this point in the history
  • Loading branch information
techniq committed Jul 30, 2024
1 parent fc18db3 commit 4c54d30
Showing 1 changed file with 40 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
<script lang="ts">
import { mdiDotsVertical, mdiPlus } from '@mdi/js';
import { Button, Drawer, Form, MultiSelect, MultiSelectOption, ToggleButton } from 'svelte-ux';
import { mdiCheck, mdiDotsVertical, mdiPlus } from '@mdi/js';
import {
Button,
Drawer,
Form,
Icon,
MultiSelect,
MultiSelectOption,
ToggleButton,
} from 'svelte-ux';
import Preview from '$lib/components/Preview.svelte';
const options = [
Expand Down Expand Up @@ -158,7 +166,7 @@
</div>
</Preview>

<h2>option slot</h2>
<h2>option slot with MultiSelectOption custom actions</h2>

<Preview>
{value.length} selected
Expand Down Expand Up @@ -203,6 +211,34 @@
</div>
</Preview>

<h2>option slot with custom markup</h2>

<Preview>
{value.length} selected
<div class="flex flex-col max-h-[360px] overflow-auto">
<MultiSelect {options} {value} on:change={(e) => (value = e.detail.value)}>
<svelte:fragment
slot="option"
let:option
let:label
let:value
let:checked
let:indeterminate
let:onChange
>
<button
class="px-2 py-1 text-surface-content flex gap-1 w-full"
role="option"
on:click={onChange}
>
<Icon data={checked ? mdiCheck : ''} />
<div>{label}</div>
</button>
</svelte:fragment>
</MultiSelect>
</div>
</Preview>

<h2>Form integration</h2>

<Preview>
Expand Down

0 comments on commit 4c54d30

Please sign in to comment.