Overlays
IConfirmDialog
A promise-based confirmation for destructive actions. confirm() resolves true if the reader confirms and false if they cancel or dismiss.
Mount one <IConfirmDialog /> in the app, typically just inside <IApp>, then call useConfirm() wherever you need it. This site mounts one, so the buttons below open the real thing.
danger styles the confirming button as destructive. Use it when the action destroys something.
The short form
A string is shorthand for { title }, which is enough when the title is the whole question.
Labels
confirmLabel and cancelLabel are set per request, falling back to the IConfirmDialog's own props. Name the action on the confirming button — "Delete invoice" rather than "OK".
One at a time
A second call supersedes the first: the earlier promise resolves false and its dialog is replaced.
The API
const { confirm } = useConfirm()
const confirmed: boolean = await confirm(options)options is a string — shorthand for the title — or:
interface ConfirmOptions {
title: string
description?: string
confirmLabel?: string
cancelLabel?: string
/** Style the confirming button as destructive. */
danger?: boolean
}The store behind it is a module-level singleton, so confirm() can be called from a plain function with no component in scope.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
confirmLabel | string | 'Confirm' | Fallback for requests that supply none |
cancelLabel | string | 'Cancel' | Fallback for requests that supply none |
size | 'sm' | 'md' | 'lg' | 'xl' | 'sm' | Dialog width; a question needs little room |
unstyled | boolean | — | Drop built-in classes |
class | string | — | Merged with the built-in classes |
Mount exactly one. For anything with fields in it, or a decision that is not a yes or a no, use IDialog.