Skip to content

Dialog

Overlay

A modal dialog: open any component or template from code with injectAtlasDialog().open(), or place <atlas-dialog> in a template and bind [open].

[atlasDialogBody][atlasDialogClose][atlasDialogDescription][atlasDialogFooter][atlasDialogHeader][atlasDialogTitle]atlas-confirm-dialogatlas-dialog

Examples

Dialog

Bind open and handle (closed) ; compose the panel with header, title, description and footer.

Confirm with the service

AtlasDialogService.confirm() and deleteConfirm() open a ready-made confirm dialog and resolve to true or false .

Result: —

Typed dialog from code

The dialog declares its result and data with injectAtlasDialogRef<Result, Data>() ; injectAtlasDialog().open() infers both, requires the data and returns a typed result . The title names the dialog on its own, and atlasDialogClose cancels.

Last result: —

Open a template

open() also takes an ng-template : it receives the ref as let-ref and the data as let-data="data" . Type the TemplateRef with AtlasDialogTemplateContext<Result, Data> and the call is typed like a component dialog.

Last result: —

Sizes and defaults

size sets the width: sm , md (default), lg , xl or full . provideAtlasDialogDefaults() in a component's providers sets defaults for the dialogs it opens with injectAtlasDialog() ; here every dialog is lg unless the call says otherwise.

Long content

The card is never taller than the screen, whatever its size . Wrap the content between the header and the footer in atlasDialogBody : it scrolls, and the title and the footer actions stay in view.

API

Generated from the library source, so it always matches the code.

AtlasDialogCloseDirective [atlasDialogClose]

InputTypeDefaultDescription
atlasDialogClose unknownundefined The result to close with; empty (the bare attribute) or undefined dismisses instead.
type 'button' | 'submit' | 'reset''button'type of the host <button> (ignored on other elements). Default: 'button' , so it never submits a form.

AtlasDialogComponent atlas-dialog

InputTypeDefaultDescription
open requiredboolean— Whether the dialog is shown. Controlled: the dialog only closes when the parent sets it to false .
class string'' Extra CSS classes, merged with the component's own through cn() ; yours win on conflicts.
size AtlasDialogSize'md' Width of the card. Default: 'md'
closeLabel string | undefinedundefined Accessible name of the close button. Defaults to the configured dialog.close text.
OutputPayloadDescription
closedvoid Emits on Escape, a backdrop click, the × button, atlasDialogClose or CDK closing on navigation: set open to false in the handler.

AtlasDialogHeaderComponent [atlasDialogHeader]

InputTypeDefaultDescription
class string'' Extra CSS classes, merged with the component's own through cn() ; yours win on conflicts.

AtlasDialogTitleComponent [atlasDialogTitle]

InputTypeDefaultDescription
class string'' Extra CSS classes, merged with the component's own through cn() ; yours win on conflicts.
id string'' Element id; defaults to <dialog id>-title . The dialog's aria-labelledby points at it.

AtlasDialogDescriptionComponent [atlasDialogDescription]

InputTypeDefaultDescription
class string'' Extra CSS classes, merged with the component's own through cn() ; yours win on conflicts.
id string'' Element id; defaults to <dialog id>-desc . The dialog's aria-describedby points at it.

AtlasDialogBodyComponent [atlasDialogBody]

InputTypeDefaultDescription
class string'' Extra CSS classes, merged with the component's own through cn() ; yours win on conflicts.

AtlasDialogFooterComponent [atlasDialogFooter]

InputTypeDefaultDescription
class string'' Extra CSS classes, merged with the component's own through cn() ; yours win on conflicts.

AtlasDialogRef<R = unknown, D = unknown>class

Reference to an open dialog, typed by its result R and its data D . The dialog component declares both with injectAtlasDialogRef<R, D>() on a public property; AtlasDialogService.open() reads them from there (ADR 0028).

MemberDescription
readonly data: D The data passed to open() .
readonly result: Promise<AtlasDialogResult<R>> Resolves once with how the dialog ended. Never rejects.
get id: string The CDK dialog id; also the prefix of the ids the dialog may give its title and description.
close(...[value]: CloseArgs<R>): void Close the dialog with a result.
dismiss(reason: AtlasDialogDismissReason = 'cancel'): void Close the dialog without a result (Cancel).
afterClosed(): Observable<R | undefined> Emits once when the dialog closes: the value passed to close() , or undefined when dismissed. Built on result , so a subscription made after the dialog closed still receives it.

AtlasDialogServiceservice

Imperative service for opening dialogs. Supports two patterns: 1. **open()** — open any component or template as a dialog, typed end to end (ADR 0028) 2. **confirm() / deleteConfirm()** — quick confirmation dialogs Built on @angular/cdk/dialog , which provides the backdrop, focus trap and focus restore, scroll blocking, and Escape delivered to the topmost dialog only. Prefer injectAtlasDialog() : its dialogs are created under the caller's injector, so they see the providers of the component that opened them.

MemberDescription
open<C, R = AtlasDialogResultOf<C>, D = AtlasDialogDataOf<C>>(content: Type<C> | TemplateRef<AtlasDialogTemplateContext<R, D>>, ...[config = {}]: AtlasDialogConfigArgs<NoInfer<D>>): AtlasDialogRef<R, D> Open a component or a template as a modal dialog. - **Component:** its result R and data D come from the public property it assigns injectAtlasDialogRef<R, D>() to. - **Template:** R and D come from its TemplateRef<AtlasDialogTemplateContext<R, D>> type; it receives the ref as $implicit and the data as data . data is required when D does not accept undefined .
confirm(options: ConfirmOptions): Promise<boolean> Open a generic confirmation dialog. Returns a Promise that resolves to true (confirmed) or false (cancelled).
deleteConfirm(options: DeleteConfirmOptions): Promise<boolean> Open a delete confirmation dialog (pre-configured as destructive). Returns a Promise that resolves to true (confirmed) or false (cancelled).

Functions

FunctionDescription
createAtlasDialogTesting<R = unknown, D = unknown>(...[options = {}]: undefined extends D ? [options?: { data?: D }] : [options: { data: D }]): AtlasDialogTesting<R, D> Test a dialog component without opening a dialog: the component injects a real AtlasDialogRef (and the context atlasDialogClose , atlasDialogTitle and atlasDialogDescription use) backed by a stand-in for the CDK ref, so close() / dismiss() resolve ref.result and nothing renders in an overlay. Like open() , it requires data when D does not accept undefined .
injectAtlasDialog(): AtlasDialogService The dialog service bound to the caller's injector: the dialogs it opens are created under the component (or service) that called it, so they see its providers. Call it in an injection context.
injectAtlasDialogRef<R = void, D = void>(): AtlasDialogRef<R, D> Inject the reference of the dialog this component is open in, typed by its result R and data D . Assign it to a public property ( @atlas/dialog-ref-public ): open() infers both types from it.
provideAtlasDialogDefaults(defaults: AtlasDialogDefaults): Provider Defaults for dialogs opened with open() . In the application providers they apply everywhere; in a component's providers they apply to dialogs that component opens with injectAtlasDialog() .

Types

AtlasDialogConfig

Options for AtlasDialogService.open() .

PropertyTypeDescription
data? D Data for the dialog, read with injectAtlasDialogRef<R, D>().data . Required when the dialog's D does not accept undefined .
size? AtlasDialogSize Width of the dialog. Default: 'md' , or the size of provideAtlasDialogDefaults()
panelClass? string Classes added to the dialog card (after the defaults' panelClass )
disableClose? boolean Whether Escape and backdrop clicks are ignored. Default: false
width? deprecatedstring Tailwind max-width class for the card; replaces the size width.
role? 'dialog' | 'alertdialog'dialog (default), or alertdialog for urgent interruptions.
ariaLabelledBy? string Id of the element that names the dialog. Default: the atlasDialogTitle inside it.
ariaDescribedBy? string Id of the element that describes the dialog. Default: the atlasDialogDescription inside it.
injector? Injector Parent injector of the dialog content. Defaults to the caller's injector with injectAtlasDialog() , and to the root injector with inject(AtlasDialogService) .

AtlasDialogConfigArgs

The config is optional when the data accepts undefined ; otherwise it is required and carries data .

type AtlasDialogConfigArgs = undefined extends D ? [config?: AtlasDialogConfig<D>] : [config: AtlasDialogConfig<D> & { data: D }]

AtlasDialogDataOf

The data type a dialog component declares with injectAtlasDialogRef<R, D>() ; unknown when it declares none.

type AtlasDialogDataOf = [DialogRefOf<C>] extends [never] ? unknown : DialogRefOf<C> extends AtlasDialogRef<unknown, infer D> ? D : unknown

AtlasDialogDefaults

App- or component-wide defaults for AtlasDialogService.open() ; each open() config wins over them.

PropertyTypeDescription
size? AtlasDialogSize Default width. Default: 'md'
disableClose? boolean Ignore Escape and backdrop clicks by default. Default: false
panelClass? string Classes added to every dialog card.

AtlasDialogDismissReason

Why a dialog closed without a result: escape , a backdrop click, cancel (the default of dismiss() ), or external (CDK closed it: navigation, Dialog.closeAll() ).

type AtlasDialogDismissReason = 'escape' | 'backdrop' | 'cancel' | 'external'

AtlasDialogResult

How a dialog ended: closed with a value, or dismissed with a reason.

type AtlasDialogResult = | { readonly type: 'closed'; readonly value: R } | { readonly type: 'dismissed'; readonly reason: AtlasDialogDismissReason }

AtlasDialogResultOf

The result type a dialog component declares with injectAtlasDialogRef<R, D>() ; unknown when it declares none.

type AtlasDialogResultOf = [DialogRefOf<C>] extends [never] ? unknown : DialogRefOf<C> extends AtlasDialogRef<infer R, unknown> ? R : unknown

AtlasDialogSize

Dialog widths. md is the default; full covers the viewport.

type AtlasDialogSize = 'sm' | 'md' | 'lg' | 'xl' | 'full'

AtlasDialogTemplateContext

Context of a dialog template: the ref as $implicit ( let-ref ) and the data as data ( let-data="data" ).

PropertyTypeDescription
$implicit AtlasDialogRef<R, D> —
data D —

AtlasDialogTesting

A dialog ref for unit tests, and the providers that make a dialog component inject it.

PropertyTypeDescription
ref AtlasDialogRef<R, D> The ref the component receives; await ref.result to assert how the component closed it.
providers Provider[] Add to TestBed.configureTestingModule({ providers }) (or the component's providers).

ConfirmDialogData

PropertyTypeDescription
title string Dialog title
message string Dialog description/message
confirmLabel? string Text for the confirm button
cancelLabel? string Text for the cancel button
destructive? boolean Whether the confirm action is destructive (red button)
icon? string Optional icon name displayed above the title

ConfirmOptions

Options for opening a confirm dialog

type ConfirmOptions = ConfirmDialogData

DeleteConfirmOptions

Options for opening a delete confirm dialog (pre-configured destructive)

PropertyTypeDescription
title? string Dialog title (defaults to 'Delete record?')
message string Dialog message
confirmLabel? string Confirm button text (defaults to 'Delete')
cancelLabel? string Cancel button text (defaults to 'Cancel')
icon? string Icon name (defaults to 'atlas:trash')

DialogOptions deprecated

Options for opening a generic component dialog.

type DialogOptions = AtlasDialogConfig<D>