Back to Components

Overlay

Dialog

Modal overlay built on bits-ui — focus trap, ESC, click-outside, portal mount, scroll lock all handled. Bind open and the consumer drives visibility.

Examples

Basic

<Button onclick={() => open = true}>Open dialog</Button>
<Dialog bind:open title="Hello" description="A simple modal.">
  <p>Body content goes here.</p>
</Dialog>

With footer

<Dialog bind:open title="Save changes?" description="Your work will be saved to the cloud.">
  <p>Body…</p>
  {#snippet footer()}
    <Button variant="ghost" onclick={() => open = false}>Cancel</Button>
    <Button onclick={() => open = false}>Save</Button>
  {/snippet}
</Dialog>

size="lg"

<Dialog bind:open size="lg" title="Wide dialog">…</Dialog>

Props

PropTypeDefaultDescription
openbooleanfalseBindable open state. Use bind:open or set + listen to onOpenChange.
titlestringHeading rendered with the display font.
descriptionstringOptional muted line below the title.
size'sm' | 'md' | 'lg''md'Max-width tier — 400 / 480 / 640.
onOpenChange(open: boolean) => voidFires whenever the dialog opens or closes.
footerSnippetOptional bottom action row.
childrenSnippetBody content.

Install

CLI

npm install bits-ui
npx @a3tai/mittsu add dialog