Confirm dialog

Asks the user to confirm an action before it happens, with one line of code: await confirm.ask(…) resolves to true or false . Use it for consequential or irreversible actions, not for routine ones.

  • vig-confirm-dialog
Import
import { ConfirmDialog, Confirm } from '@vigdx/ui/confirm-dialog';

Basic

Place <vig-confirm-dialog /> once in the app shell (see the app.ts tab; this site already does). Then inject the Confirm service anywhere and await its ask() with a message and an optional heading .

Draft

Destructive action

variant: 'error' styles the accept button as destructive. acceptLabel and rejectLabel name the outcome of each button, which is clearer than a generic “Confirm”.

  • budget-2026.xlsx
  • logo-final.svg
  • contract.pdf

Default labels

Without heading or labels, the host's localized defaults apply (“Are you sure?”, “Confirm”, “Cancel”); set them app-wide through the vig-confirm-dialog inputs. Escape, the X button and a backdrop click resolve to false .

Styling hooks

Internal elements carry a stable data-part and the component's data-scope; both are public API, so removing one is a breaking change. Select a part by both, e.g. [data-scope="confirm-dialog"][data-part="message"] { … }: the pair stays within this component when kit components nest, and also reaches parts in overlay panels, which render outside the host. State is exposed through aria-* and, where listed, a data-state; literal values are checked by the API gate, values computed from the component's state follow its documented types. Other data-* attributes listed below (such as data-opening while an overlay animates) are API too. See Customizing.

Scope: [data-scope="confirm-dialog"]

ConfirmDialog styling hooks
Part Element data-state
message The message paragraph (inside the dialog body). —
reject The reject vig-button . —
accept The accept vig-button . —

Accessibility

  • Renders a vig-dialog, so it is a native modal <dialog>: the page is inert, focus is trapped and Escape cancels.
  • It opens with focus on the reject button, the safe answer, so a reflexive Enter never confirms a destructive action.
  • The dialog is named by its header; the message is plain text in the body, so write it as a complete sentence that makes sense on its own.
  • Focus returns to the button that asked once the dialog closes, whatever the answer.
  • All built-in strings (heading, acceptLabel, rejectLabel, closeAriaLabel) are inputs on the host and options per call, for i18n.

API

ConfirmDialog

vig-confirm-dialog component

Host for the Confirm service — place once in the app shell. Renders the pending request in a vig-dialog; label defaults are inputs for i18n and can be overridden per call via ConfirmOptions. The dialog opens with focus on the reject (safe) action.

ConfirmDialog props
Name Type Default Description
acceptLabelstring | undefinedundefined
—
closeAriaLabelstring | undefinedundefined
—
headerstring | undefinedundefined

Deprecated: Use `heading`; still honored when `heading` is unset.

—
headingstring | undefinedundefined

Default title; ConfirmOptions.heading overrides it per call.

rejectLabelstring | undefinedundefined
—
widthstring'var(--container-dialog-sm)'

CSS width; defaults to the --container-dialog-sm token.

Confirm

injectable

Imperative confirmation flow (PrimeNG ConfirmationService territory): place once in the app shell, then

Example :
if (await this.confirm.ask({ message: 'Delete this record?', variant: 'error' })) { … }

Resolves false on reject and on any dismissal (Escape, X, backdrop).

Confirm methods
Signature Description
ask(options: ConfirmOptions): Promise<boolean>
—
settle(accepted: boolean): void

Settles and closes the pending request; no-op when nothing is open.

Are you sure?