Create

Feedback

Alert Dialog

Copy page View as Markdown Open in ChatGPT Open in Claude

A modal dialog that interrupts the user with important content and expects a response.

Usage#

app.component.ts
import { WdsAlertDialogComponent } from '@wds/angular/alert-dialog';

Use it for a decision the user must make before going on, such as confirming a deletion. For other content in a window use Dialog.

Examples#

Default#

show() opens the dialog, and the buttons in the footer slot close it with close(). There is no close button and a click on the backdrop does nothing; Escape works like Cancel. The first button (Cancel) gets focus.

Show dialogCancelContinue

Small with media#

size="sm" makes a narrow, centered dialog with the buttons side by side. An icon in the media slot shows above the title.

Connect accessoryDon't allowAllow

Destructive#

A destructive button for an action that deletes data. Cancel stays first, so a quick Enter does not delete anything.

Delete chatCancelDelete

Service#

In Angular, WdsAlertDialogService.open() builds the dialog from the config: title, description, cancelText / okText, okDestructive and size. closed emits true after OK and undefined after Cancel or Escape; content (content, data) works as in WdsDialogService. HTML and React have no service, so their tabs show the same dialog declared in the markup.

Discard draftResult: none

API References#

wds-alert-dialog#

A modal dialog that interrupts the user with important content and expects a response, e.g. a confirmation before deleting data (role="alertdialog"). It has no close button and a click on the backdrop does not close it: the user answers with the buttons in the footer slot. Escape works like Cancel. Put the safe action (Cancel) first in the footer: the dialog focuses the first button when it opens.

Attributes

AttributeTypeDefaultDescription
sizeWdsAlertDialogSize'default'sm: a narrow, centered dialog with the buttons side by side.
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 (a button calling close(), Escape), before the exit animation.
wds-after-closeCustomEvent<void>After the exit animation.

Methods

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

Slots

SlotDescription
(default)Extra content under the description (often empty).
headingCustom heading (instead of the heading attribute).
descriptionCustom description (instead of the description attribute).
mediaAn icon above the title (e.g. a warning sign).
footerThe answers, e.g. Cancel and Delete buttons.

CSS parts (::part)

PartDescription
dialogThe native <dialog>.
panelThe content container.
headerThe header.
mediaThe icon box.
titleThe title.
descriptionThe description.
bodyThe content.
footerThe footer.

CSS custom properties

PropertyDescription
--wds-dialog-widthWidth of the window (default 32rem, with size="sm" 20rem).

Accessibility#

Screen reader#

The window is a modal role="alertdialog" named by heading and described by description (aria-labelledby, aria-describedby), so screen readers read the question when it opens.

The rest of the page is inert while the dialog is open, and focus stays inside it.

The icon in the media slot is decorative: give it aria-hidden="true" and say everything in the title and the description.

Name the buttons by what they do ("Delete", "Keep editing"), not "Yes" and "No".

Keyboard support#

KeyFunction
TabMoves focus to the next button. Focus does not leave the dialog.
ShiftTabMoves focus to the previous button.
EnterActivates the focused button.
SpaceActivates the focused button.
EscapeCloses the dialog like Cancel.
Footer