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
| Name | Type | Default | Description |
|---|---|---|---|
| title | string | '' | Headline. Ask a question. |
| body | string | '' | What will actually happen, and whether it can be undone. |
| confirmLabel | string | '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:
| Property | Default | Controls |
|---|---|---|
| --hk-confirm-danger | #b91c1c | Confirm 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.