Overlays Core Stable

AlertDialog

A confirmation dialog for consequential, hard-to-undo actions — fixed confirm/cancel actions, never dismissed by an outside click

Preview

Installation

pnpm add fancy-ui-svelte
import { AlertDialog } from 'fancy-ui-svelte'

Usage

svelte
<script lang="ts">
  import { AlertDialog } from 'fancy-ui-svelte';
</script>

<AlertDialog />

Examples

Basic Usage

A destructive delete confirmation with a trigger.

Controlled Open

Non-bound open plus onOpenChange, triggered from a list row.

Custom Labels

A non-delete use case — signing out of every device.

Props

PropTypeDefaultDescription
open booleanfalseWhether the alert dialog is open; bindable
onOpenChange (open: boolean) => void-Fires whenever open changes — Confirm, Cancel, or Escape
title string-The heading. Omitted entirely (not just visually) when not given
description string-The warning copy under the title. Same omission rule as title
confirmLabel string"Confirm"Label of the destructive action
cancelLabel string"Cancel"Label of the safe action
onConfirm () => void-Called when the destructive action is activated, before the surface closes
onCancel () => void-Called when the safe action is activated, and also when Escape closes it
initialFocus HTMLElement | null-Element to focus once the surface opens; defaults to the Cancel button
class string-Additional CSS classes for the panel
ref HTMLDivElement | nullnullBindable reference to the panel element

Slots

SlotDescription
triggerOptional trigger; renders in place and opens the surface on activation