Dialog
A modal dialog that interrupts the user with important content and expects a response.
Import
import Dialog from '$lib/components/Dialog.svelte'; Basic Example
let open = false;
<Button variant="primary" label="Open Dialog" onclick={() => open = true} />
<Dialog bind:open>
<div class="flex flex-col gap-4">
<div class="flex items-center justify-between">
<h2 class="text-lg font-semibold">Dialog Title</h2>
<button
class="rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-foreground focus-visible:ring-offset-2 focus-visible:ring-offset-background active:scale-98"
onclick={() => open = false}
>
<svg use:inlineSvg={{ src: '/icons/Close.svg' }} class="size-5 text-foreground" />
<span class="sr-only">Close</span>
</button>
</div>
<Separator.Root class="-mx-5 block h-px bg-muted" />
<p>Dialog content goes here...</p>
<div class="flex justify-end gap-2">
<Button variant="outline" label="Cancel" onclick={() => open = false} />
<Button variant="primary" label="Save" onclick={() => open = false} />
</div>
</div>
</Dialog>Properties
Name
Type
Description
open
Type
boolean
Default: false
Controls the open state of the dialog
class_name
Type
string
Default: ""
Additional classes to apply to the dialog content