Search documentation

Search the documentation and open a page.

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

Loading...

Installation

pnpm dlx shadcn@latest add @wirekyt/alert-dialog

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

InputTypeDefaultDescription
idstring | undefinedgeneratedUnique identifier used to connect the dialog parts.
idsPartial<DialogElementIds> | undefined—Overrides generated identifiers for individual parts.
aria-labelstring | undefined—Accessible label used when no visible title labels the dialog.
openboolean | undefined—Open state when controlled. Supports Angular two-way binding.
defaultOpenbooleanfalseInitial open state when uncontrolled.
modalbooleantrueEnables modal behavior.
closeOnInteractOutsidebooleantrueCloses the dialog after an allowed outside interaction.
closeOnEscapebooleantrueCloses the dialog when Escape is pressed.
preventScrollbooleantruePrevents document scrolling while the dialog is open.
trapFocusbooleantrueKeeps keyboard focus inside the open dialog.
restoreFocusbooleantrueRestores 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.
triggerValuestring | null | undefined—Active trigger value when controlled. Supports two-way binding.
defaultTriggerValuestring | null | undefined—Initial active trigger value when uncontrolled.

Outputs

OutputTypeDescription
openChangeboolean | undefinedEmits the updated controlled open state.
triggerValueChangestring | null | undefinedEmits the updated controlled trigger value.
escapeKeyDownKeyboardEventEmits when Escape is pressed.
focusOutsideDialogFocusOutsideEventEmits when focus moves outside the dialog.
interactOutsideDialogInteractOutsideEventEmits for an interaction outside the dialog.
pointerDownOutsideDialogPointerDownOutsideEventEmits for a pointer-down event outside the dialog.
requestDismissCustomEventEmits when another layer requests that this one dismiss.
openChangeDetailsDialogOpenChangeDetailsEmits detailed information about an open-state change.
triggerValueChangeDetailsDialogTriggerValueChangeDetailsEmits detailed information about a trigger-value change.

[app-alert-dialog-trigger]

InputTypeDefaultDescription
valuestring | undefined—Value used to identify this trigger when activated.

<app-alert-dialog-content>

InputTypeDefaultDescription
size"default" | "sm""default"Controls the dialog panel size and responsive layout.
classstring""Additional classes applied to the inner content panel.

Context, Provider, and Utilities

ExportAngular API
DialogRootProviderDirective that provides an externally created dialog API through value.
DialogContextStructural 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.
AlertDialogImportsReadonly collection containing the alert dialog components and context helpers.