Create

Feedback

Dialog

Copy page View as Markdown Open in ChatGPT Open in Claude

A window overlaid on either the primary window or another dialog window, rendering the content underneath inert.

Usage#

app.component.ts
import { WdsDialogComponent } from '@wds/angular/dialog';

Examples#

Default#

show() and close() open and close the dialog; heading and description name and describe it. Buttons go to the footer slot. wds-close fires when the dialog starts closing, wds-after-close after the exit animation.

Edit profile
NameUsername
CancelSave changes

Scrollable content#

The dialog is at most as tall as the screen; longer content scrolls between the header and the footer.

Scrollable content

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Accept

Width#

--wds-dialog-width sets the width (default 32rem); on a narrow screen the dialog keeps a margin from the edges.

NarrowWide
CloseClose

Static backdrop#

With static-backdrop a click on the backdrop does not close the dialog. dismissible set to false (a property) also blocks Escape; with hide-close the dialog then closes only from your own button.

Static backdropNot dismissible
CloseI understand

Confirm#

In Angular, WdsDialogService.open() builds a confirmation from the config alone: title, description, okText / cancelText (footer buttons), okDestructive and width. closed emits true after OK and undefined after any other way of closing. HTML and React have no service, so their tabs show the same dialog declared in the markup.

Delete projectResult: none

Service#

In Angular, WdsDialogService.open(Component, config) renders a component in the dialog: data goes to the component through WDS_OVERLAY_DATA, and the component closes the dialog with WdsOverlayRef.close(value); the value comes out of closed. HTML and React have no service, so their tabs show the same dialog declared in the markup.

RenameProject: My project

API References#

wds-dialog#

A modal window over the page. Closed with Escape, a click on the backdrop, the close button or close().

Attributes

AttributeTypeDefaultDescription
openbooleanfalseControls visibility. Also set by show() and close().
headingstring''Title (or the heading slot).
descriptionstring''Description under the title (or the description slot), linked as aria-describedby.
hide-close.hideClosebooleanfalseHides the close button in the header.
static-backdrop.staticBackdropbooleanfalseA click on the backdrop does not close it.
dismissiblebooleantruefalse blocks closing with Escape, the backdrop (and dragging in a drawer).
close-label.closeLabelstring'Zamknij'Label of the close button.

Events

EventDescription
wds-closeCustomEvent<void>Closing (button, Escape, backdrop, close()), before the exit animation.
wds-after-closeCustomEvent<void>After the exit animation.

Methods

MethodDescription
show()Opens it.
close()Closes it.

Slots

SlotDescription
(default)Content. An element with autofocus gets focus when it opens (otherwise the first focusable element).
headingCustom heading (instead of the heading attribute).
descriptionCustom description (instead of the description attribute).
footerActions, such as buttons.

CSS parts (::part)

PartDescription
dialogThe native <dialog>.
panelThe content container.
headerThe header.
titleThe title.
descriptionThe description.
closeThe close button.
bodyThe content.
footerThe footer.

CSS custom properties

PropertyDescription
--wds-dialog-widthWidth of the window (default 32rem).

Accessibility#

Screen reader#

The dialog is a native modal <dialog> named by heading and described by description (aria-labelledby, aria-describedby). Always give it a heading; hide it visually if the design has no title.

While it is open, the rest of the page is inert and focus stays inside; when it closes, focus returns to the element that opened it.

The close button is named by close-label (default Zamknij, in Polish). With hide-close and dismissible set to false, keep a button in the dialog that closes it.

Keyboard support#

KeyFunction
TabShift + TabMoves focus between the controls of the dialog; focus stays inside.
EscapeCloses the dialog (unless dismissible is false).
Footer