Confirm

One question, a distinct verb, and nothing drawn by the browser.

Confirm only what cannot be undone. Anything reversible acts at once and offers Undo in a toast. These dialogs are div-based, so they stay visible in a screen share, and the page behind is inert.

data-confirm

Put <.confirm_host /> in the layout once. Every element with data-confirm then opens the styled dialog instead of window.confirm() . The click is caught before LiveView sees it and replayed on the verb.

Button, link and form
Link (danger tone)

confirm_dialog

Write the question in HEEx and open it with SutraUI.open_confirm/1 . Focus starts on Keep for a danger action; Escape means Keep; focus returns to the trigger. values arrive as event params and the inner block holds extra fields.

A dialog you write

Retire this course?

Learners keep their certificates; nobody can start it again.

Remove Asha?

She loses access today.

Host-controlled

Pass show and on_cancel to let the LiveView hold the open state. Keep, Escape and the backdrop push on_cancel .

Host-controlled

Delete this workbook?

Its 3 sections and 40 submissions are removed for everyone.

Notes

  • The dialog is an alertdialog : it names the action, says what happens in one line and offers "Keep it" next to a verb ("Delete", "Retire"), never "OK".
  • Without a host on the page, data-confirm keeps phoenix_html's own browser prompt.
  • In LiveView tests data-confirm is ignored, so clicks go straight through; use SutraUI.Confirm.Test.confirm/2 to run the verb of a confirm_dialog .

Are you sure?