Dialog
A modal overlay on the native dialog element, for forms, settings and other content that blocks the page.
<arc-dialog>Overview
Dialog is the general overlay, built on the native <dialog> element, so the browser handles the top layer, ::backdrop and modality. It opens over a blurred backdrop, moves focus inside, and returns focus to where it came from when it closes. Use it for forms, settings, previews and multi-step flows where the page behind shouldn't be usable.
Renamed in v4. This component was arc-modal through v3. That tag was removed in v4.0.0, not aliased. The v3 arc-dialog tag was a small confirm prompt, and that component is now arc-confirm. If you pass this Dialog the old prompt props (message, confirm-label, cancel-label), it logs a console.error that points you to arc-confirm.
dismissible is on by default. It shows the X button and lets Escape and a backdrop click close the dialog. Set it to false for decisions the user has to make with the footer buttons. arc-close is cancelable, so preventDefault() keeps the dialog open, for example while a form inside it is saving.
Guidelines
Do
- Keep `dismissible` on unless closing by accident would lose the user's work
- Put actions in the `footer` slot, with the confirming action last
- Use `size="sm"` for short single-purpose dialogs, and `lg` only for dense content
Don't
- Don't use it for a yes-or-no question. Use `arc-confirm`, which already has the two buttons
- Don't stack dialogs. Close one before opening another
- Don't use it for passive notices. Use Alert or Toast, which don't take focus
Features
- The backdrop's dim and blur come from `--dialog-backdrop` and `--dialog-backdrop-filter`
- Slides up and fades in on open, and reverses on close
- `size` sets the max width: `sm` is 400px, `md` 560px and `lg` 720px. `fullscreen` fills the viewport
- `header` and `footer` slots around the body
- `heading` is the text in the header bar and the dialog's accessible name
Preview
Usage
This component needs JavaScript. Use the Web Component or a framework wrapper.
<arc-button id="edit">Edit Profile</arc-button>
<arc-dialog heading="Edit Profile" size="sm">
<arc-input label="Display Name"></arc-input>
<div slot="footer">
<arc-button variant="ghost" data-close>Cancel</arc-button>
<arc-button variant="primary" data-close>Save Changes</arc-button>
</div>
</arc-dialog>
<script>
const dialog = document.querySelector('arc-dialog');
document.getElementById('edit').addEventListener('click', () => {
dialog.open = true;
});
dialog.addEventListener('click', (e) => {
if (e.target.closest('[data-close]')) dialog.open = false;
});
</script>import { Dialog, Button, Input } from '@arclux/arc-ui-react';
import { useState } from 'react';
function EditProfile() {
const [open, setOpen] = useState(false);
return (
<>
<Button onClick={() => setOpen(true)}>Edit Profile</Button>
<Dialog heading="Edit Profile" size="sm" open={open} onArcClose={() => setOpen(false)}>
<Input label="Display Name" />
<div slot="footer">
<Button variant="ghost" onClick={() => setOpen(false)}>Cancel</Button>
<Button variant="primary" onClick={() => setOpen(false)}>Save Changes</Button>
</div>
</Dialog>
</>
);
}<script setup>
import { ref } from 'vue';
import { Dialog, Button, Input } from '@arclux/arc-ui-vue';
const open = ref(false);
</script>
<template>
<Button @click="open = true">Edit Profile</Button>
<Dialog heading="Edit Profile" size="sm" :open="open" @arc-close="open = false">
<Input label="Display Name" />
<div slot="footer">
<Button variant="ghost" @click="open = false">Cancel</Button>
<Button variant="primary" @click="open = false">Save Changes</Button>
</div>
</Dialog>
</template><script>
import { Dialog, Button, Input } from '@arclux/arc-ui-svelte';
let open = false;
</script>
<Button on:click={() => (open = true)}>Edit Profile</Button>
<Dialog heading="Edit Profile" size="sm" {open} on:arc-close={() => (open = false)}>
<Input label="Display Name" />
<div slot="footer">
<Button variant="ghost" on:click={() => (open = false)}>Cancel</Button>
<Button variant="primary" on:click={() => (open = false)}>Save Changes</Button>
</div>
</Dialog>import { Component } from '@angular/core';
import { Dialog, Button, Input } from '@arclux/arc-ui-angular';
@Component({
imports: [Dialog, Button, Input],
template: `
<arc-button (click)="open = true">Edit Profile</arc-button>
<arc-dialog heading="Edit Profile" size="sm" [open]="open" (arc-close)="open = false">
<arc-input label="Display Name" />
<div slot="footer">
<arc-button variant="ghost" (click)="open = false">Cancel</arc-button>
<arc-button variant="primary" (click)="open = false">Save Changes</arc-button>
</div>
</arc-dialog>
`,
})
export class EditProfileComponent {
open = false;
}import { Dialog, Button, Input } from '@arclux/arc-ui-solid';
import { createSignal } from 'solid-js';
function EditProfile() {
const [open, setOpen] = createSignal(false);
return (
<>
<Button onClick={() => setOpen(true)}>Edit Profile</Button>
<Dialog heading="Edit Profile" size="sm" open={open()} on:arc-close={() => setOpen(false)}>
<Input label="Display Name" />
<div slot="footer">
<Button variant="ghost" onClick={() => setOpen(false)}>Cancel</Button>
<Button variant="primary" onClick={() => setOpen(false)}>Save Changes</Button>
</div>
</Dialog>
</>
);
}import { Dialog, Button, Input } from '@arclux/arc-ui-preact';
import { useState } from 'preact/hooks';
function EditProfile() {
const [open, setOpen] = useState(false);
return (
<>
<Button onClick={() => setOpen(true)}>Edit Profile</Button>
<Dialog heading="Edit Profile" size="sm" open={open} onArcClose={() => setOpen(false)}>
<Input label="Display Name" />
<div slot="footer">
<Button variant="ghost" onClick={() => setOpen(false)}>Cancel</Button>
<Button variant="primary" onClick={() => setOpen(false)}>Save Changes</Button>
</div>
</Dialog>
</>
);
}API
REUSED_TAG_PROPSarray['message', 'confirmLabel', 'cancelLabel']- The props that belonged to the *old*
arc-dialog. V4-SCOPE §3.3 requires this and says why: the oldarc-dialogwas a confirm prompt withheading,messageandconfirmLabel, and it merged intoarc-confirm. Anyone still writing that markup upgrades into this primitive, which knowsheadingand would silently ignore the other two, rendering an empty panel with a title. That is the quietest possible failure, and a line in MIGRATION.md is not a fix for it.headingis not in the list: it means the same thing in both components, so its presence is not evidence of the mistake. headingstring''- Text displayed in the header bar, and the dialog's accessible name. Keep it short and action-oriented (e.g. "Delete Project" rather than "Are you sure?").
openbooleanfalse- Controls the visible state of the dialog. Set to
trueto open it and move focus inside; set tofalseto run the exit animation and restore focus to wherever it came from. size'sm' | 'md' | 'lg''md'- Controls the maximum width of the dialog panel.
sm(400px) is ideal for simple confirmations,md(560px) for standard forms, andlg(720px) for content-heavy dialogs with tables or multi-column layouts. dismissiblebooleantrue- When
true, renders the built-in X close button and allows dismissal via Escape key and backdrop click. Set tofalsefor critical decisions the user must resolve through the footer buttons. Note the default: a dialog is dismissible unless you say otherwise, where an alert is not dismissible unless you say so; the name is the convention, the default belongs to the component. fullscreenbooleanfalse- Makes the dialog fill the entire viewport. Useful for mobile forms or complex workflows.
Events
arc-close- Fired when the dialog closes. Cancelable:
preventDefault()vetoes the close. arc-open- Fired when the dialog opens
See also
- ConfirmConfirmation prompt built on Dialog. Call ArcConfirm.open() and await a true or false answer.
- SheetA panel that slides in from the bottom or right edge of the screen over a blurred backdrop.
- DrawerA panel that slides in from the left or right edge, for navigation menus, filters and detail views.