Dojo NG is being built in the open, one section at a time — follow along on Heptapod.

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.

Try it in the playground

@dojo-ng/dialog · v0.1.3

npm install @dojo-ng/dialog

import "@dojo-ng/dialog";

Properties

PropertyAttributeTypeDefault
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

SlotDescription
title
Default slotcontent
actions

CSS parts

Style these with dj-dialog::part(name).

underlaydialogtitleclosecontentactions

CSS custom properties

PropertyDefaultDescription
--dj-dialog-z-index941Stacking order of the dialog.
--dj-dialog-underlay-z-index940Stacking order of the dialog underlay (scrim).

Methods

close()