skip section navigation

DialogContainer

DialogContainer is the native dialog wrapper behind Loafkit’s views. use it when the task needs a custom body and you want to keep the library’s opening, closing and backdrop behavior.

Ready to share?

Open the saved links once before sending the collection.

usage

svelte
<script>
	import { DialogContainer } from '@ciabi/loafkit-ui';
	let open = $state(false);
	let close = $state(() => {});
</script>

<button type="button" onclick={() => open = true}>Review the collection</button>
<DialogContainer id="review-collection" bind:open bind:close aria-labelledby="review-collection-title">
	<section>
		<h2 id="review-collection-title">Ready to share?</h2>
		<p>Open the saved links once before sending the collection.</p>
		<button type="button" onclick={() => close()}>Back to reading</button>
	</section>
</DialogContainer>

composition

  • DialogContainer
    • custom body
      • heading + content
      • explicit close/cancel action

props

name a custom dialog with aria-labelledby pointing to its visible heading, or use aria-label.

keep the task usable

native showModal() provides modal focus behavior. keep a clear close or cancel action inside, especially if dismissal is disabled. the container doesn’t submit forms, save changes or validate fields. use SmallDialogView when its title, body and footer structure already fits.

require an explicit decision

share this collection?

confirm this local example, or keep it private.

not reviewed

svelte
<script lang="ts">
import { DialogContainer } from '@ciabi/loafkit-ui';
let reviewOpen = $state(false);
let reviewClose = $state<() => void>(() => {});
let reviewResult = $state('not reviewed');
</script>

<button type="button" onclick={() => reviewOpen = true}>review before sharing</button>
<DialogContainer id="explicit-review" bind:open={reviewOpen} bind:close={reviewClose} dismissible={false} aria-labelledby="explicit-review-title">
	<section><h2 id="explicit-review-title">share this collection?</h2>
		<p>confirm this local example, or keep it private.</p>
		<button type="button" onclick={() => { reviewResult = 'kept private'; reviewClose(); }}>keep private</button>
		<button type="button" onclick={() => { reviewResult = 'sharing confirmed'; reviewClose(); }}>confirm sharing</button>
	</section>
</DialogContainer>
<p role="status">{reviewResult}</p>

API reference

DialogContainer

Component
id

unique ID used by the component and its control relationships.

open
Default: true

whether the dialog is open.

dismissible
Default: true

allows ordinary Escape and backdrop dismissal.

managed
Default: false

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

onClose

called when normal closing finishes.

class
Default: ''

extra classes on the dialog wrapper.

style

inline styles on the dialog wrapper.

aria-labelledby

ID of the visible dialog heading.

aria-label

an explicit accessible name.

close
Default: () => {}

the container-provided function for normal animated closing.

children

custom dialog body and its explicit actions.