PickerDialogView
offer named choices or media in a modal grid. selection calls your callback; your app decides when to close.
article collection: weekend reading
usage
<script lang="ts">
import { PickerDialogView } from '@ciabi/loafkit-ui';
let open = $state(false);
let selected = $state('weekend reading');
const items = [{ label: 'weekend reading' }, { label: 'garden notes' }, { label: 'recipes' }];
</script>
<button type="button" onclick={() => open = true}>move article</button>
<PickerDialogView id="move-article" title="choose a collection" description="pick the shelf where you want to keep it."
bind:open {items} buttons={[{label: 'cancel'}]}
onSelect={item => { selected = item.label ?? ''; open = false; }} />
<p role="status">article collection: {selected}</p>composition
- PickerDialogView
- iconContent()(optional)
- children(optional)
- items(optional)
- itemContent(item, number)(optional)
- footer(close) or buttons(optional)
custom items and confirmation
destination shelf: weekend reading
<script lang="ts">
import { PickerDialogView } from '@ciabi/loafkit-ui';
import headerArtwork from '$lib/assets/emotions/awkward.png';
let previewPickerOpen = $state(false);
let previewShelf = $state('weekend reading');
</script>
<button type="button" onclick={() => previewPickerOpen = true}>preview destination shelf</button>
<PickerDialogView id="preview-shelf-picker" title="where should this article go?" bind:open={previewPickerOpen}
items={[{label:'weekend reading'},{label:'garden notes'}]} onSelect={item => previewShelf = item.label ?? ''}>
{#snippet iconContent()}<img src={headerArtwork} alt="" style="width: 1.25rem; height: 1.25rem; object-fit: cover;" />{/snippet}
<p>choose a shelf to preview its contents.</p>
{#snippet itemContent(item, number)}
<strong>{number}. {item.label}</strong>
<span class="loaf-subtext">{item.label === 'garden notes' ? 'pots and plants' : 'long reads'}</span>
{/snippet}
{#snippet footer(close)}<p>previewing: {previewShelf}</p><button type="button" onclick={close}>done</button>{/snippet}
</PickerDialogView>
<p role="status">destination shelf: {previewShelf}</p>itemContent replaces the item visual and receives a one-based number. keep it passive: the picker already supplies the choice button. selection does not close automatically; this example uses an explicit done action.
media thumbnails
chosen media: none yet
<script lang="ts">
import { PickerDialogView, type DialogPickerItem } from '@ciabi/loafkit-ui';
import coverOne from '$lib/assets/flavorartwork/skypiea.gif';
import coverTwo from '$lib/assets/flavorartwork/onigashima.jpg';
import coverThree from '$lib/assets/flavorartwork/romance-dawn.webp';
import headerArtwork from '$lib/assets/emotions/awkward.png';
let mediaOpen = $state(false);
let selectedMedia = $state('none yet');
const mediaItems: DialogPickerItem[] = [
{label: 'cover one', type: 'photo', imageSrc: coverOne},
{label: 'cover two', type: 'video', imageSrc: coverTwo, thumbnailSrc: coverTwo},
{label: 'cover three', type: 'gif', imageSrc: coverThree, thumbnailSrc: coverThree}
];
</script>
<button type="button" onclick={() => mediaOpen = true}>choose flavor artwork</button>
<PickerDialogView id="garden-media" title="choose flavor artwork" description="pick an image preview."
bind:open={mediaOpen} items={mediaItems}
onSelect={item => { selectedMedia = item.label ?? ''; mediaOpen = false; }} />
<p role="status">chosen media: {selectedMedia}</p>thumbnailSrc is used only when imageSrc is present. video choices display images, not a video player; gif choices use an image too. add a meaningful label so the accessible name doesn’t fall back to the media type and number. Icon or iconSrc can replace the default category symbol.
API reference
PickerDialogView
id-
unique dialog ID, also used for its title relationship.
open- Default:
truewhether the dialog is open.
title- Default:
'select an option'the visible dialog heading.
description- Default:
'choose from the options below'supporting text beneath the heading.
iconSrc-
header image, used after iconContent and Icon.
Icon-
header component, used after iconContent.
iconContent-
custom passive header artwork.
itemContent-
custom visual content inside each choice button; receives the item and one-based number.
children-
content before the choice grid.
items-
choices to render in the grid.
buttons-
footer actions when no footer snippet is supplied.
onSelect-
called with the chosen item.
dismissible- Default:
trueallows the container’s ordinary dismissal paths.
managed- Default:
falsemarks a helper-managed view; leave false for a directly mounted picker.
onClose-
called when the dialog closes.
close- Default:
() => {}the container-provided close function.
class- Default:
''extra classes passed to the dialog container.
style-
inline styles passed to the dialog container.
aria-label-
fallback accessible name when no visible title is supplied.
DialogPickerItem
one choice supplied to a picker dialog.
type-
the media category; rendering falls back to photo when unset.
label-
the visible name and choice button’s accessible name.
imageSrc-
enables an image preview.
thumbnailSrc-
preview image used instead of imageSrc; only used when imageSrc is present.
iconSrc-
category icon image, used when Icon is absent.
Icon-
category icon component, taking precedence over iconSrc.
footer action fields are documented in the dialog API guide.