Confirm

stable 1.9 kB
<HkConfirmService>

A service, not a template. Ask returns a promise, so a destructive action reads as a single await instead of a callback and a boolean flag.

#dialog#service

Live demo

Running in this page — interact with it.

Inputs

NameTypeDefaultDescription
titlestring''Headline. Ask a question.
bodystring''What will actually happen, and whether it can be undone.
confirmLabelstring'Confirm'Primary button label — name the action, not "OK".
tone'default' | 'danger''default'Danger restyles the confirm button.

Methods

  • ask(options)Promise<boolean>

    Opens the dialog and resolves true on confirm, false on cancel or dismiss.

Keyboard

  • Escape Cancels, resolving false
  • Enter Confirms
  • Tab Cycles within the dialog

Theming

Component tokens, each falling back to a global one:

PropertyDefaultControls
--hk-confirm-danger#b91c1cConfirm button fill in danger tone.

Accessibility

  • role="alertdialog" so the prompt interrupts rather than waiting to be discovered.
  • Initial focus lands on the confirm button; Escape always resolves false, never leaving the promise pending.

More in Overlay