Alert Dialog
A modal dialog that interrupts the user with important content and expects a response. Requires Alpine.js.
Usage
el.getClientRects().length > 0);
if (!nodes.length) { $event.preventDefault(); return; }
const first = nodes[0];
const last = nodes[nodes.length - 1];
if ($event.shiftKey && document.activeElement === first) { $event.preventDefault(); last.focus(); }
else if (!$event.shiftKey && document.activeElement === last) { $event.preventDefault(); first.focus(); }
"
x-transition:enter="transition ease-out duration-200"
x-transition:enter-start="opacity-0 scale-95"
x-transition:enter-end="opacity-100 scale-100"
x-transition:leave="transition ease-in duration-150"
x-transition:leave-start="opacity-100 scale-100"
x-transition:leave-end="opacity-0 scale-95"
@click.stop
class="fixed top-1/2 left-1/2 z-[51] grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-lg border bg-background p-6 shadow-lg outline-none sm:max-w-lg"
>
Are you absolutely sure?
This action cannot be undone. This will permanently delete your account and remove your data from our servers.
Composition
code
AlertDialog
├── AlertDialogTrigger
└── AlertDialogContent
├── AlertDialogHeader / Title / Description
└── AlertDialogFooter
├── AlertDialogCancel
└── AlertDialogAction