ReferenceDialogs
media-alert-dialog
A modal alert dialog for urgent messages that require acknowledgement
Import
Anatomy
Behavior
Use an alert dialog for an urgent message that interrupts the user and requires acknowledgement. Your application controls when it opens and supplies its content.
<media-alert-dialog> adds alert semantics, while the other parts are the same elements <media-dialog> uses. For general modal content, including a player opened from a thumbnail, use <media-dialog> instead.
Set the root’s open property to show the dialog. The root supplies alert state while the shared media-dialog-backdrop and media-dialog-popup siblings render the visual surfaces and semantics. The root updates the property and dispatches open-change when the dialog closes.
The close part and Escape close the dialog. The dialog stays rendered during a closing transition, then restores focus to the element that was focused before it opened.
Styling
Use the open and transition data attributes to style visibility and animations:
Accessibility
The dialog uses role="alertdialog" and aria-modal="true". The title and description receive generated IDs that are connected with aria-labelledby and aria-describedby. Focus moves into the dialog when it opens, stays within it while open, and returns to the previously focused element when it closes. Content outside the dialog is inert while it is open. Pressing Escape closes the dialog.
Examples
Basic usage
API Reference
media-alert-dialog
A modal dialog with alert semantics.
Props
State
media-dialog-backdrop
Presentational backdrop that reflects its owning dialog's state.
Data attributes
media-dialog-close
Button that closes its owning dialog; the element itself takes role="button" and keyboard focus.
Data attributes
media-dialog-description
Text announced as its owning dialog's description. The element takes the id that the popup's aria-describedby
points to.