Alert Dialog
Asks the user to confirm or cancel before a destructive or irreversible action. Clicking outside does not close it.
Installation
Copy the command below and run it in your terminal.
Usage
Set error on AlertDialog.Root to give AlertDialog.Confirm the destructive style and turn supported browser chrome red while the dialog is open.
Examples
Destructive confirmation
Sign out confirmation
Anatomy
AlertDialog.Root - Controls alert dialog state.
AlertDialog.Trigger - Opens the alert dialog.
AlertDialog.Content - Renders the dialog surface.
AlertDialog.Header - Groups dialog heading content.
AlertDialog.Title - Renders the dialog title.
AlertDialog.Description - Renders the dialog description.
AlertDialog.Exit - Closes the dialog without confirming.
AlertDialog.Footer - Groups dialog actions.
AlertDialog.Confirm - Confirms and closes the dialog.
<script lang="ts"> import Trash from '@lucide/svelte/icons/trash-2'; import * as AlertDialog from '@sivir-ui/svelte/components/alert-dialog'; import Shortcut from '@sivir-ui/svelte/components/shortcut'; </script> <AlertDialog.Root error> <AlertDialog.Trigger variant="destructive"> <Trash size={14} /> Delete workspace </AlertDialog.Trigger> <AlertDialog.Content size="lg"> <AlertDialog.Header> <div class="flex items-center gap-2.5"> <Trash size={18} class="text-[var(--color-error)]" /> <AlertDialog.Title>Delete this workspace?</AlertDialog.Title> </div> <AlertDialog.Description> All projects, comments, and exports will be removed. This action cannot be undone. </AlertDialog.Description> </AlertDialog.Header> <AlertDialog.Footer> <AlertDialog.Exit> Cancel <Shortcut shortcut="esc" /> </AlertDialog.Exit> <AlertDialog.Confirm> Delete <Shortcut shortcut="enter" /> </AlertDialog.Confirm> </AlertDialog.Footer> </AlertDialog.Content> </AlertDialog.Root>