skip section navigation

SmallDialogView

SmallDialogView provides a title, optional message and footer around a modal task. render it directly when the dialog’s form state belongs to the surrounding component.

collection: Weekend notes

usage

svelte
<script>
	import { SmallDialogView, Field, FieldLabel, Input } from '@ciabi/loafkit-ui';
	let open = $state(false);
	let title = $state('Weekend notes');
	let saved = $state('Weekend notes');
</script>

<button type="button" onclick={() => open = true}>rename collection</button>
<SmallDialogView id="rename-collection" title="Rename this collection" bind:open leftAligned>
	<form id="rename-collection-form" onsubmit={event => {
		event.preventDefault(); saved = title; open = false;
	}}>
		<Field>
			<FieldLabel htmlFor="rename-title">Collection name</FieldLabel>
			<Input id="rename-title" bind:value={title} required />
		</Field>
	</form>
	{#snippet footer(close)}
		<button type="button" onclick={close}>cancel</button>
		<button type="submit" form="rename-collection-form">save name</button>
	{/snippet}
</SmallDialogView>
<p>collection: {saved}</p>

composition

  • SmallDialogView
    • iconContent()(optional)
    • illustrationContent()(optional)
    • children(optional)
    • footer(close) or buttons(optional)

artwork

named emotions need registration; direct artwork belongs to your app. see app artwork for registration and receiving-component rules.

for app-wide messages without local view ownership, use createDialog with type: 'small' instead. don’t pass that discriminator to a direct SmallDialogView.

keep a failed save editable

this demo fails the first save so you can correct or retry it.

svelte
<script lang="ts">
import { SmallDialogView, Field, FieldLabel, Input } from '@ciabi/loafkit-ui';
let retryOpen = $state(false);
let retryNote = $state('mint needs its own pot');
let retrySaving = $state(false);
let retryError = $state('');
let retryAttempts = $state(0);
let retrySaved = $state('');
async function saveRetryNote(event: SubmitEvent) {
	event.preventDefault();
	if (retrySaving) return;
	retrySaving = true; retryError = '';
	await new Promise(resolve => setTimeout(resolve, 400));
	retryAttempts += 1;
	if (retryAttempts === 1) retryError = 'the demo save failed. your note is still here; try again.';
	else { retrySaved = retryNote; retryOpen = false; }
	retrySaving = false;
}
</script>

<button type="button" onclick={() => { retryAttempts = 0; retryError = ''; retryOpen = true; }}>edit garden note</button>
<SmallDialogView id="retry-note-dialog" title="save a garden note" bind:open={retryOpen} dismissible={!retrySaving} leftAligned>
	<form id="retry-note-form" onsubmit={saveRetryNote} aria-busy={retrySaving}>
		<Field><FieldLabel htmlFor="retry-note">garden note</FieldLabel>
			<Input id="retry-note" multiline bind:value={retryNote} disabled={retrySaving} required aria-describedby="retry-note-error" />
		</Field>
		<p id="retry-note-error" role="status">{retryError}</p>
	</form>
	{#snippet footer(close)}
		<button type="button" disabled={retrySaving} onclick={close}>cancel</button>
		<button type="submit" form="retry-note-form" disabled={retrySaving}>{retrySaving ? 'saving…' : 'save note'}</button>
	{/snippet}
</SmallDialogView>
{#if retrySaved}<p role="status">saved note: {retrySaved}</p>{/if}

artwork and configured actions

you can bring it back when you need it.

the collection is still active.

svelte
<script lang="ts">
	import { SmallDialogView } from '@ciabi/loafkit-ui';
	import archiveIcon from '$lib/assets/emotions/angry.png';
	import archiveIllustration from '$lib/assets/flavorartwork/alabasta.jpg';
	let artworkOpen = $state(false);
	let archiveChoice = $state('the collection is still active.');
</script>

<button type="button" onclick={() => artworkOpen = true}>review archive choice</button>
<SmallDialogView id="artwork-archive" bind:open={artworkOpen} title="archive this collection?"
	bodyText="you can bring it back when you need it." leftAligned
	buttons={[{label:'cancel'},{label:'archive locally',main:true,action:() => archiveChoice = 'the demo collection is archived.'}]}>
	{#snippet iconContent()}<img src={archiveIcon} alt="" style="width: 1.25rem; height: 1.25rem; object-fit: cover;" />{/snippet}
	{#snippet illustrationContent()}<img src={archiveIllustration} alt="" style="width: 4rem; height: 4rem; object-fit: cover; border-radius: 50%;" />{/snippet}
</SmallDialogView>
<p role="status">{archiveChoice}</p>

API reference

SmallDialogView

Component
id

unique ID used by the component and its control relationships.

open
Default: true

whether the dialog is open.

emoticon

registered decorative artwork name.

icon

built-in warning artwork key.

iconSrc

the decorative icon image.

Icon

a Svelte icon component.

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.

children

custom body content.

footer

custom footer receiving the close function; replaces configured buttons.

title
Default: ''

the visible heading.

bodyText
Default: ''

the main message text.

bodySubText
Default: ''

secondary message text.

buttons

configured footer actions when no custom footer is supplied.

dismissible
Default: true

allows ordinary Escape and backdrop dismissal.

managed
Default: false

marks a helper-managed view; leave false for a direct view.

leftAligned
Default: false

left-aligns the message content.

onClose

called when normal closing finishes.

close
Default: () => {}

the container-provided function for normal animated closing.

class
Default: ''

extra classes on the dialog wrapper.

style

inline styles on the dialog wrapper.

aria-label

an explicit accessible name.