dialogs
use createDialog for an app-wide message or picker opened from a browser action. it mounts the view itself, so you donāt need DialogHolder in your layout.
<script>
import { createDialog } from '@ciabi/loafkit-ui';
let exported = $state(false);
function confirmExport() {
createDialog({
id: 'export-reading-list', type: 'small', title: 'Export this reading list?',
bodyText: 'make a local copy of the articles in this list.',
buttons: [
{ label: 'Cancel' },
{ label: 'prepare export', main: true, action: () => exported = true }
]
});
}
</script>
<button type="button" onclick={confirmExport}>export reading list</button>
{#if exported}<p role="status">export requested in this demo. no file was downloaded.</p>{/if}choose who owns the dialog
managed dialogs have one current instance. calling createDialog replaces the previous managed instance. the helper returns void; callbacks carry the result of the action back into your app.
for a form with local state, render SmallDialogView or PickerDialogView directly and use bind:open. that makes the dialog part of your componentās lifecycle. for a fully custom body, use DialogContainer.
browser and mounting boundary
call createDialog from a browser event or after mounting. it throws during server rendering. the default target is document.body; pass { target } as its second argument when your dialog needs to inherit styles from a particular element. root flavor variables naturally reach the body.
killDialog(id?) immediately disposes the current managed instance, optionally only when its ID matches. direct views are controlled through their own open or close binding instead. see the dialog API reference for button timing, action behavior and item data.