A window overlaid on either the primary window or another dialog window, rendering the content underneath inert.
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-dialog> ├── [appDialogTrigger] └── <app-dialog-content> ├── [appDialogHeader] │ ├── [appDialogTitle] │ └── [appDialogDescription] ├── content ├── [appDialogFooter] (optional) └── [appDialogClose] (optional)
Examples
Default
Loading...
In A Form
Loading...
No Close Button
Loading...
Review Transfer
Loading...
Schedule Report
Loading...
Scrollable Content
Loading...
Settings
Loading...
Share Link
Loading...
Sticky Footer
Loading...
Upgrade Plan
Loading...
Welcome
Loading...
API Reference
<app-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. |
role | "dialog" | "alertdialog" | undefined | "dialog" | Sets the dialog's accessible role. |
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. |
[appDialogTrigger]
| Input | Type | Default | Description |
|---|---|---|---|
value | string | undefined | — | Value used to identify this trigger when activated. |
<app-dialog-content>
| Input | Type | Default | Description |
|---|---|---|---|
showCloseButton | boolean | true | Shows the built-in close button in the content panel. |
class | string | "" | Additional classes applied to the inner content panel. |
Context, Providers, 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. |
useDialog(options) | Creates the signal-backed dialog machine in an Angular injection context. |
injectDialogContext() | Injects the nearest dialog root context. |
injectDialogContextCarrier() | Injects the context carrier used across portals. |
DialogImports | Readonly collection containing the dialog UI and context helpers. |
Types
| Export | Description |
|---|---|
DialogApi | Connected dialog state and actions. |
DialogElementIds | Overrides for generated dialog part IDs. |
DialogMachineProps | Configuration accepted by the underlying dialog machine. |
DialogOpenChangeDetails | Details emitted by openChangeDetails. |
DialogTriggerValueChangeDetails | Details emitted by triggerValueChangeDetails. |
DialogFocusOutsideEvent | Event emitted by focusOutside. |
DialogInteractOutsideEvent | Event emitted by interactOutside. |
DialogPointerDownOutsideEvent | Event emitted by pointerDownOutside. |
UseDialogOptions | Options accepted by useDialog. |
UseDialogProps | Dialog props supplied by the useDialog context callback. |
UseDialogReturn | Signal-backed dialog machine returned by useDialog. |
Angular
React
Solid
Svelte
Vue