Actions
Danger zone
A red box with a warning and a Delete button that asks for confirmation in a dialog before running a destructive action. Use it at the end of a settings or edit page, for deleting the record, closing the account and the like.
Danger Zone
Nothing to show
A red box titled "Danger Zone", with a message saying the record and its data will be lost for good, and a red Delete button under it. Delete opens a dialog asking "Do you really want to delete this record?" with Cancel and Confirm; Confirm calls deleteAccount and closes the dialog, Cancel or Escape closes it without doing anything. Every default text is translated.
Your own texts #
title and message change the box. trigger: reaches the Delete button, here with another label and an icon. modal: reaches the dialog: its title, the subtitle under it, and the confirm button through modal:confirm:, whose label stays "Confirm" unless you change it.
Delete project
Nothing to show
Your own content #
Content in the default slot takes the place of the Delete button and the dialog: the box shows the title, the message and the two buttons, and nothing asks for confirmation.
Close account
Nothing to show
Rendering from data #
One box per project, each with its own dialog. Confirming in the second box calls deleteProject(2).
Delete Website redesign
Delete Mobile app
Nothing to show
Message as a list #
An array in message renders as a list, useful to spell out what will be lost.
Delete workspace
Nothing to show
Alert styles #
The box is a tk:alert: type, variant, border and size pass to it, and trigger:variant changes the button.
Transfer ownership
Revoke all sessions
Nothing to show
Prepend and actions #
The prepend slot goes before the title and actions at the end of the row.
Archive repository
Nothing to show
Events #
confirmed bubbles from the confirm button, so it can be heard on the tag with Alpine.
Remove integration
Integration removed.
Nothing to show
Customization #
Classes go to the box; title:, trigger: and modal: reach the parts. With modal:auto-close bound to false the dialog stays open after Confirm until the action closes it.
Danger Zone
Nothing to show
Reference
Danger zone
| Prop | Type | Default | Description |
|---|---|---|---|
title |
string | Danger Zone |
The heading of the box, translated. |
message |
string | array | By deleting this record, all associated data will be permanently lost and cannot be recovered. |
The text under the title, translated. An array renders as a list. |
prepend |
slot | null |
Content before the title. |
actions |
slot | null |
Controls at the end of the row. |
The box is a tk:alert, and the other alert props pass to it (type, variant, icon, border, closable, size...); type defaults to danger.
Slots
| Slot | Description |
|---|---|
| default | Replaces the Delete button and the dialog. |
prepend |
Content before the title. |
actions |
Controls at the end of the row. |
Events
| Event | Detail | When |
|---|---|---|
confirmed |
The confirm button of the dialog was clicked. |
Prefixes
| Prefix | Goes to |
|---|---|
trigger: |
The Delete button, as props and attributes of tk:button (trigger:label, trigger:icon, trigger:size...). |
modal: |
The dialog, as props and attributes of tk:modal.confirm: modal:title, modal:subtitle, modal:confirm (the Livewire action), modal:cancel, modal:name, and its own prefixes modal:confirm:, modal:cancel: and modal:actions:. |
title:, message:, icon:, container:, actions:, close: |
The parts of the box, as in tk:alert. |
Events
The event bubbles from the confirm button through the box, so it can be heard on the tag or on any element around it.
The dialog's own opened and closed do not reach the tag. With closable, the box dispatches the alert events (before-dismiss, dismissed).
With Alpine:
Nothing to show
Calling a Livewire action:
Nothing to show
Customization
Classes and attributes go to the box, the root element of the alert. To reach an inner element, prefix the attribute (listed in the Reference above).
Nothing to show
The box gets a thick red border on the left and its title is an <h2>. With :modal:auto-close="false" the dialog stays open after Confirm, so the action can close it when it is done; the bound form is needed, since the string "false" keeps it closing.
Accessibility
The box has role="group" and aria-labelledby pointing to its title, and aria-live="off": unlike a tk:alert of type danger, it is part of the page and is not announced when the page loads. Pass role to change it.
The dialog follows the WAI-ARIA alert dialog pattern: role="alertdialog", named by its title and described by its subtitle. When it opens the focus goes to Cancel, so pressing Enter by accident does not confirm; when it closes the focus returns to the Delete button.
| Key | Action |
|---|---|
| Enter, Space | On the Delete button, opens the dialog. |
| Tab | Moves from Cancel to Confirm. |
| Enter | Runs the focused button: Cancel closes the dialog, Confirm runs the action and closes it. |
| Escape | Closes the dialog without confirming. |
Behavior notes
- The box and the Delete button are red by default;
typeandtrigger:variantchange them. titleandmessagetake only strings. Atitleormessageslot is ignored, and the default text shows in its place.modal:andtrigger:attributes do nothing when the default slot has content, since there is no dialog or button to receive them.- The confirm button is red, but its label is "Confirm" (translated); pass
modal:confirm:labelfor a label that names the action. - The title id is the tag's
idfollowed by-title, or a generated one when there is noid. - Inside Livewire the Delete button still opens its dialog after an update, and each box in a
@foreachkeeps its own dialog.