Skip to content

Confirm action

An alert dialog's confirm button that shows a loader and stays focusable while its action runs.

Use AlertDialogPendingAction in place of AlertDialogAction when confirming starts a request. It does not close the dialog: close it when the request succeeds. variant is destructive unless you set default, which is the primary button.

Delete that asks first

Drafts deleted: 0

Not destructive

Reminders sent: 0

Installation

npx shadcn@latest add @khaeli/confirm-action

Install @khaeli/foundation first: this item's styling lives in its tokens and [data-slot] rules.

Installs with

Registry items

Keyboard

EnterSpace
On the trigger, opens the dialog and moves focus to Cancel. On the confirm button, starts the action. While pending the confirm button keeps focus as aria-disabled and further presses do nothing.
TabShift+Tab
Move between Cancel and the confirm button. Focus stays inside the dialog.
Escape
Closes the dialog and returns focus to the trigger. A request that is already running is not cancelled: keep the dialog open while pending, as these examples do.

Accessible name

  • The confirm button's name is its text. Name the action, not the answer (Delete draft, not Yes), and change it while pending to say what is happening, such as Deleting. The loader is hidden from assistive technology.
  • The dialog takes its name from AlertDialogTitle and its description from AlertDialogDescription.

Registry JSON

The item as the shadcn CLI reads it, with every file it ships: https://ui.khaeli.com/r/confirm-action.json