dialog API
createDialog(config, options?) opens one managed message or picker. DialogInfo is a union of SmallDialog and PickerDialog, selected by the exact type string. both need an id.
Saved in Weekend reading
<script>
import { createDialog } from '@ciabi/loafkit-ui';
let collection = $state('Weekend reading');
function moveArticle() {
createDialog({
id: 'api-move-article', type: 'picker', title: 'Move article',
description: 'Choose where to keep this article.',
items: [{ label: 'Weekend reading' }, { label: 'Garden notes' }],
onSelect: item => {
collection = item.label ?? '';
},
buttons: [{ label: 'done', main: true }]
});
}
</script>
<button type="button" onclick={moveArticle}>Choose collection</button>
<p role="status">Saved in {collection}</p>delay availability, then await the action
the archive button becomes available after a short countdown. its action finishes before the dialog closes.
demo collection is active
<script lang="ts">
import { createDialog } from '@ciabi/loafkit-ui';
let archiveResult = $state('demo collection is active');
function openArchiveDemo() {
createDialog({
id:'archive-example', type:'small', title:'archive the demo collection?', icon:'warn-red',
bodyText:'this only changes local example state. your real collections stay as they are.',
buttons:[
{label:'cancel'},
{label:'archive demo',color:'red',timeout:1000,action:async () => {
archiveResult = 'archiving demo…';
await new Promise(resolve => setTimeout(resolve,400));
archiveResult = 'demo collection archived';
}}
]
});
}
</script>
<button type="button" onclick={openArchiveDemo}>try a delayed archive action</button>
<p role="status">{archiveResult}</p>the timeout delays availability; it never confirms automatically. resolved actions close normally regardless of their return value. rejected actions prevent normal closing but do not supply error or loading UI. use the custom-footer save example for recoverable form work.
closing and ownership
killDialog() disposes the current managed view immediately. killDialog(id) only acts if the ID matches. replacement and forced disposal aren’t the normal close path; don’t rely on onClose for every replacement or kill.
for recoverable forms use SmallDialogView’s custom footer. for passive custom items and image thumbnails, use PickerDialogView. its canonical DialogPickerItem reference owns that shape.
configuration reference
SmallDialog and PickerDialog combine the shared fields with their respective fields below. DialogInfo is their union, selected by type. these configuration types do not expose the direct view’s open/close bindings or managed flag.
Dialog (shared fields)
shared fields of SmallDialog and PickerDialog; the base Dialog type is not exported.
SmallDialog
the small variant of DialogInfo, combined with the shared fields.
type-
the managed view kind.
emoticon-
registered decorative artwork name.
icon-
built-in warning artwork key (warn-red).
iconSrc-
header icon image.
Icon-
header Svelte icon.
illustrationSrc-
illustration image above the message panel.
Illustration-
illustration component above the message panel.
iconContent-
custom passive header artwork.
illustrationContent-
custom artwork above the message panel.
title-
visible heading.
bodyText-
primary body message.
bodySubText-
secondary body message.
buttons-
configured footer actions.
leftAligned-
left-aligns message content.
PickerDialog
the picker variant of DialogInfo, combined with the shared fields.
type-
the managed view kind.
title-
visible heading.
description-
supporting picker text.
iconSrc-
header icon image.
Icon-
header Svelte icon.
iconContent-
custom passive header artwork.
itemContent-
passive visual content within each choice button; number is one-based.
items-
the picker choices.
buttons-
configured footer actions.
onSelect-
called with the chosen item; does not close automatically.
DialogMountOptions
mount options passed to createDialog.
target-
mount target; otherwise document.body is used.
DialogButton
one configured dialog action.
label-
visible action name.
color-
destructive action treatment.
main-
emphasizes the primary action.
timeout-
milliseconds of initial disabled countdown for buttons.
action-
callback awaited before a button closes normally.
href-
renders a link instead of a button.
class-
classes on the action.
style-
styles on the action.
link actions are not awaited and do not use the disabled countdown. rejected button actions prevent normal closing but supply no loading/error UI. use a custom footer for pending state and recovery.