Axon 911 Frontend DocsAxon 911 Frontend Docs
Axon 911 Frontend Docs
    Loading navigation…
U
User
Switch to light mode
  1. Blocks
  2. Confirm Dialog
  3. API and Development

Confirm Dialog

API and Development

View SourceOpens in a new tabSubmit IssueOpens in a new tab
Import ConfirmDialog, ConfirmDialogConfirmation, ConfirmDialogVariant from @prepared911/ui/blocks/confirm-dialog. The declaration in packages/ui/src/blocks/confirm-dialog/schema.ts is the contract for inputs, slots, composed components, and variants. Prop types and TSDoc are in packages/ui/src/blocks/confirm-dialog/props.ts.
PropTypeDefault
titleLocalizedMessage, required
descriptionLocalizedMessage, required
confirmLabelLocalizedMessage, required
cancelLabelLocalizedMessage, required
onConfirm() => void | PromiseLike<void>, required
pendingLabelLocalizedMessageconfirmLabel as the name, nothing announced
variantConfirmDialogVariant: Default, DestructiveDefault
confirmDisabledboolean; a typed dialog also needs the text to matchfalse
confirmationConfirmDialogConfirmation: None, TypedNone
errorLocalizedMessagenone
triggerOne Button or Linknone
childrenExtra content before the actionsnone
open, defaultOpen, onOpenChange(open, details)Controlled or uncontrolled open stateuncontrolled, closed
ref, classNameThe dialog element and its surface class
Typed confirmation
Set confirmation={ConfirmDialogConfirmation.Typed} and the next props become required or available. An untyped dialog rejects all four at compile time.
PropTypeDefault
phrasestring, required: the text to type (a record name, or a fixed word for a bulk action)
instructionLocalizedMessage, required: the words before the phrase, such as "To continue, type"
instructionEndLocalizedMessage: the words after the phrase, such as "in the field below."the sentence ends with the phrase
matchedLabelLocalizedMessage: announced politely when the text first matchesnothing announced
ConfirmDialogProps is ConfirmDialogBaseProps and either the untyped or the typed props (ConfirmDialogUntypedProps, ConfirmDialogTypedProps). Use ConfirmDialogBaseProps to extend or Partial the props every dialog takes.
Props
NameTypeDefaultDescription
cancelLabelLocalizedMessage—Label of the cancel Button.
confirmLabelLocalizedMessage—Label of the confirm Button.
descriptionLocalizedMessage—What the action does and what it costs. Describes the dialog. Name the affected entity here.
onConfirm() => void | PromiseLike<void>—The caller's action, run when the confirm Button is pressed. Return nothing and the dialog closes at once. Return a promise and the confirm Button shows its loading state, the cancel Button is unavailable, and Escape does not close the dialog until the promise settles; a fulfilled promise then closes it. A rejected promise keeps it open and is not rethrown: report the failure from the handler and pass error.
titleLocalizedMessage—Heading that names the dialog. Always visible.
childrenReactNode—Extra content between the description and the actions, such as the records an action affects. A typed confirmation field sits below it.
classNamestring—Classes appended to the dialog surface. Put overrides in @layer chroma.overrides.
confirmationConfirmDialogConfirmationConfirmDialogConfirmation.NoneTurns the type-to-confirm field on. What the person does before the confirm action is available.
confirmDisabledbooleanfalseMakes the confirm Button inert until the caller allows it, such as an acknowledgement the caller tracks itself. It combines with {@link ConfirmDialogTypedProps}: a typed confirmation stays inert until the text matches and this is false. A pending confirm is shown as loading, not disabled.
defaultOpenbooleanfalseInitial open state when uncontrolled.
errorLocalizedMessage—A failure to show above the actions, such as why the last confirm did not complete. It is announced when it appears. Clear it by passing undefined.
instructionLocalizedMessage—The words before the phrase in the field's label and instruction, such as "To continue, type". The label reads instruction, then the phrase, then instructionEnd. Do not repeat the phrase here. Only a typed confirmation takes instruction copy.
instructionEndLocalizedMessage—The words after the phrase, such as "in the field below." Omit it when the sentence ends with the phrase. Only a typed confirmation takes instruction copy.
matchedLabelLocalizedMessage—Announced politely when the typed text first matches, such as "Confirmation text matches. Delete is available." Omit it to announce nothing. Only a typed confirmation announces a match.
onOpenChange((open: boolean, details: DialogOpenChangeDetails) => void)—Called once per open or close request: trigger press, cancel press (close-press), a settled confirm (close-press), and Escape (close-request). A backdrop press never closes the dialog. A cancelable request is vetoed with details.cancel(). While a confirm is pending, close requests are vetoed before this is called. @param open - The requested open state @param details - Change metadata
openboolean—Controlled open state. Pair with {@link ConfirmDialogProps.onOpenChange}.
pendingLabelLocalizedMessage—Announced politely and used as the confirm Button's name while a confirm is pending, such as "Deleting incident". Omit it to keep confirmLabel as the name and announce nothing.
phrasestring—The text the person must type: the name of the record being deleted, or a fixed word for a bulk action. This is data, not copy; the block shows it in a left-to-right run and compares what is typed with it after trimming surrounding whitespace and normalizing to Unicode NFC. The comparison is case-sensitive. An empty phrase never matches, so the confirm Button stays inert. Only a typed confirmation takes a phrase.
refRef<HTMLDialogElement>—Ref to the rendered dialog element.
triggerDialogControlElement—One Button or Link that opens the dialog. Omit it when the caller controls open.
variantConfirmDialogVariantConfirmDialogVariant.DefaultHow the confirm action reads.
Storybook
Interactive examples and edge cases for this component are in Storybook.
DefaultOpens in a new tab
Previous
Confirm Dialog / Usage
Next
Confirm Dialog / Accessibility
On this page
Typed confirmation
Props
Storybook