API REFERENCE · OVERLAYS
<dj-dialog>
A modal dialog. Slots: title, default (content), actions. Locks body scroll while open, closes on Escape and the close button, and on underlay click unless modal. role="alertdialog" is always modal. Restores focus to the previously focused element on close. Emits dj-close on the dialog itself; it does not bubble, so a listener on an outer element never hears an inner overlay close.
Escape closes only the overlay opened last: a select's list open inside the dialog closes first, and the dialog stays open until the next Escape. The dialog always traps focus and is announced as modal (aria-modal="true"); modal only stops an underlay click from closing it.
Accessible name: the title slot names the dialog. With no title, put aria-label on <dj-dialog> and it is passed to the inner dialog element.
role picks dialog or alertdialog for the inner dialog element. A role attribute written on <dj-dialog> is read into the property and then removed from the host, so assistive tech sees one dialog, not two nested ones.
npm install @dojo-ng/dialog
import "@dojo-ng/dialog";
Properties
| Property | Attribute | Type | Default |
|---|---|---|---|
open |
open reflected |
boolean |
false |
closeable |
closeable |
boolean |
true |
modal |
modal |
boolean |
false |
underlay |
underlay |
boolean |
true |
roledialog or alertdialog. Applied to the inner dialog element, never to the host. |
role |
"dialog""alertdialog" |
"dialog" |
ariaLabelAccessible name used when the title slot is empty. Mirrors the host's aria-label. |
aria-label |
string | null |
null |
closeText |
close-text |
string |
None |
Events
dj-close
Slots
| Slot | Description |
|---|---|
title | |
| Default slot | content |
actions |
CSS parts
Style these with dj-dialog::part(name).
underlaydialogtitleclosecontentactions
CSS custom properties
| Property | Default | Description |
|---|---|---|
--dj-dialog-z-index | 941 | Stacking order of the dialog. |
--dj-dialog-underlay-z-index | 940 | Stacking order of the dialog underlay (scrim). |
Methods
close()