Confirm dialog
await confirm.ask(…) resolves to true or false . Use it for consequential or irreversible actions, not for routine ones.
vig-confirm-dialog
import { ConfirmDialog, Confirm } from '@vigdx/ui/confirm-dialog';Basic
<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 .
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
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"]
| Part | Element | data-state |
|---|---|---|
message | — | |
reject | vig-button . | — |
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-dialogHost 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.
| Name | Type | Default | Description |
|---|---|---|---|
acceptLabel | string | undefined | undefined | — |
closeAriaLabel | string | undefined | undefined | — |
header | string | undefined | undefined | Deprecated: Use `heading`; still honored when `heading` is unset. — |
heading | string | undefined | undefined | Default title; |
rejectLabel | string | undefined | undefined | — |
width | string | 'var(--container-dialog-sm)' | CSS width; defaults to the |
Confirm
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).
| Signature | Description |
|---|---|
ask(options: ConfirmOptions): Promise<boolean> | — |
settle(accepted: boolean): void | Settles and closes the pending request; no-op when nothing is open. |