Skip to content

Alert Dialog

Delete this project?

Every deployment, environment and log will be removed. This cannot be undone.

<button class="btn btn-destructive" data-pk-dialog-open="confirm-delete">Delete</button>
<dialog class="alert-dialog" id="confirm-delete">
<div class="alert-dialog-header">
<h3 class="alert-dialog-title">Delete this project?</h3>
<p class="alert-dialog-description">This cannot be undone.</p>
</div>
<div class="alert-dialog-footer">
<button class="btn btn-outline" data-pk-dialog-close>Cancel</button>
<button class="btn btn-destructive" data-pk-dialog-close="confirm">Delete</button>
</div>
</dialog>

Title

The consequence, spelled out.

ClassPart
.alert-dialogThe <dialog> element itself
.alert-dialog-headerTitle area, centred on small screens
.alert-dialog-mediaOptional icon that pairs with the title
.alert-dialog-titleHeading — becomes the accessible name
.alert-dialog-descriptionThe consequence, spelled out
.alert-dialog-footerCancel and confirm
AttributeOnMeaning
data-pk-dialog-open="<id>"any controlOpens it
data-pk-dialog-close[="<value>"]a control insideCloses it, optionally setting returnValue
data-size="sm"the alert dialogCompact: stays narrow and splits the footer into two columns
data-state="open" | "closed"the alert dialogSet by the runtime

The events are the dialog’s: pk:dialog:before-open, pk:dialog:open and pk:dialog:close.

Leave without saving?

Your changes will be lost.

data-size="sm" keeps the panel narrow at every width and gives the two actions equal halves, which suits a short yes-or-no.

Discard draft?

Your unsaved changes will be lost.

.alert-dialog-media sits above the title on a small screen and moves beside it once there is room.

Revoke access?

This member loses access immediately and any tokens they created stop working.

Delete file?

It will not go to the bin.

The confirm button carries the destructive variant, and the description says exactly what is lost.

Delete your account?

Every project, deployment and invoice goes with it. This cannot be undone.

Set dir="rtl" on the page or on any subtree — padding, corners and positions follow the reading direction on their own. See the button page for a live example.

The title asks, the description says what happens, and the confirm button names the action rather than agreeing:

<h3 class="alert-dialog-title">Delete this project?</h3>
<p class="alert-dialog-description">Every deployment and log will be removed.</p>
...
<button class="btn btn-destructive" data-pk-dialog-close="confirm">Delete</button>

Cancel comes first in the markup so it is the first thing keyboard and screen reader users reach, and it renders last on wider screens.

document.getElementById("delete-project").addEventListener("pk:dialog:close", (event) => {
if (event.detail.returnValue === "confirm") deleteProject();
});

Esc closes it, the same as any dialog, and counts as cancelling — returnValue is empty. Treat anything other than your confirm value as “no”.