A modal dialog that interrupts the user with important content and expects a response.
Loading...
Installation
Install the following dependencies:
Copy and paste the following code into your project.
Loading...
Update the import paths to match your project setup.
Composition
<app-alert-dialog> ├── [app-alert-dialog-trigger] └── <app-alert-dialog-content> ├── [app-alert-dialog-header] │ ├── [app-alert-dialog-media] (optional) │ ├── [app-alert-dialog-title] │ └── [app-alert-dialog-description] └── [app-alert-dialog-footer] ├── [app-alert-dialog-cancel] └── [app-alert-dialog-action]
Examples
Default
Loading...
Destructive
Loading...
Small With Media
Loading...
Small
Loading...
With Media
Loading...
API Reference
<app-alert-dialog>
Inputs
| Input | Type | Default | Description |
|---|---|---|---|
id | string | undefined | generated | Unique identifier used to connect the dialog parts. |
ids | Partial<DialogElementIds> | undefined | — | Overrides generated identifiers for individual parts. |
aria-label | string | undefined | — | Accessible label used when no visible title labels the dialog. |
open | boolean | undefined | — | Open state when controlled. Supports Angular two-way binding. |
defaultOpen | boolean | false | Initial open state when uncontrolled. |
modal | boolean | true | Enables modal behavior. |
closeOnInteractOutside | boolean | true | Closes the dialog after an allowed outside interaction. |
closeOnEscape | boolean | true | Closes the dialog when Escape is pressed. |
preventScroll | boolean | true | Prevents document scrolling while the dialog is open. |
trapFocus | boolean | true | Keeps keyboard focus inside the open dialog. |
restoreFocus | boolean | true | Restores focus after the dialog closes. |
initialFocusEl | (() => HTMLElement | null) | undefined | — | Returns the element that should receive initial focus. |
finalFocusEl | (() => HTMLElement | null) | undefined | — | Returns the element that should receive focus after closing. |
persistentElements | (() => Element | null)[] | undefined | — | Elements that remain interactive while the modal is open. |
triggerValue | string | null | undefined | — | Active trigger value when controlled. Supports two-way binding. |
defaultTriggerValue | string | null | undefined | — | Initial active trigger value when uncontrolled. |
Use [(open)]="open" and [(triggerValue)]="triggerValue" for two-way binding, or pair each input with its corresponding change output when using signals.
Outputs
| Output | Type | Description |
|---|---|---|
openChange | boolean | undefined | Emits the updated controlled open state. |
triggerValueChange | string | null | undefined | Emits the updated controlled trigger value. |
escapeKeyDown | KeyboardEvent | Emits when Escape is pressed. |
focusOutside | DialogFocusOutsideEvent | Emits when focus moves outside the dialog. |
interactOutside | DialogInteractOutsideEvent | Emits for an interaction outside the dialog. |
pointerDownOutside | DialogPointerDownOutsideEvent | Emits for a pointer-down event outside the dialog. |
requestDismiss | CustomEvent | Emits when another layer requests that this one dismiss. |
openChangeDetails | DialogOpenChangeDetails | Emits detailed information about an open-state change. |
triggerValueChangeDetails | DialogTriggerValueChangeDetails | Emits detailed information about a trigger-value change. |
[app-alert-dialog-trigger]
| Input | Type | Default | Description |
|---|---|---|---|
value | string | undefined | — | Value used to identify this trigger when activated. |
<app-alert-dialog-content>
| Input | Type | Default | Description |
|---|---|---|---|
size | "default" | "sm" | "default" | Controls the dialog panel size and responsive layout. |
class | string | "" | Additional classes applied to the inner content panel. |
Context, Provider, and Utilities
| Export | Angular API |
|---|---|
DialogRootProvider | Directive that provides an externally created dialog API through value. |
DialogContext | Structural directive [dialog-context] exposing the root API to a template. |
useDialog(options) | Creates the signal-backed dialog machine inside an Angular injection context. |
injectDialogContext() | Injects the nearest dialog root context. |
injectDialogContextCarrier() | Injects the context carrier used across portals. |
AlertDialogImports | Readonly collection containing the alert dialog components and context helpers. |
Angular
React
Solid
Svelte
Vue