Alert Dialog Modal with role="alertdialog" for confirm/cancel flows. Use slot="actions" for buttons. Open/close via openAlertDialog_* / closeAlertDialog_* on window.
Add this component The command below includes <strong>AlertDialog</strong>—run it in your project directory to install this component (and the CSS if needed). No prompts.
Choose your package manager — click a tab to select, then copy the command.
npx rizzo-css add AlertDialog pnpm dlx rizzo-css add AlertDialog npx rizzo-css add AlertDialog bunx rizzo-css add AlertDialog Example Live Example
Delete item? This action cannot be undone.
Cancel Delete
Open alert dialog Usage Usage Full example for each framework (Astro, Vanilla, Svelte, Vue, React). Switch framework via View as or by clicking a Usage tab—both stay in sync.
Astro Vanilla Svelte Vue React ---
import AlertDialog from '../components/astro/AlertDialog.astro';
---
<AlertDialog id="alert-demo" title="Delete item?" description="This action cannot be undone.">
<button type="button" slot="actions" class="btn" data-alert-dialog-close>Cancel</button>
<button type="button" slot="actions" class="btn btn-error" data-alert-dialog-close>Delete</button>
</AlertDialog>
<button type="button" class="btn" onclick="window.openAlertDialog_alert_demo()">Open</button> <!-- Use .alert-dialog-root so overlay stacks behind the dialog. openAlertDialog_<id>(), closeAlertDialog_<id>(). -->
<div class="alert-dialog-root">
<div class="alert-dialog__overlay" data-alert-dialog-overlay id="alert-demo-overlay" aria-hidden="true"></div>
<div class="alert-dialog" id="alert-demo" role="alertdialog" aria-modal="true" aria-labelledby="alert-demo-title" aria-describedby="alert-demo-desc" data-alert-dialog aria-hidden="true" hidden>
<div class="alert-dialog__content">
<h2 id="alert-demo-title" class="alert-dialog__title">Delete item?</h2>
<p id="alert-demo-desc" class="alert-dialog__description">This action cannot be undone.</p>
<div class="alert-dialog__actions">
<button type="button" class="btn" data-alert-dialog-close>Cancel</button>
<button type="button" class="btn btn-error" data-alert-dialog-close>Delete</button>
</div>
</div>
</div>
</div>
<button type="button" class="btn" onclick="window.openAlertDialog_alert_demo()">Open</button> <script>
import { AlertDialog } from '$lib/rizzo';
</script>
<AlertDialog id="alert-demo" title="Delete item?" description="This action cannot be undone." bind:open>
<button type="button" class="btn" data-alert-dialog-close>Cancel</button>
<button type="button" class="btn btn-error" data-alert-dialog-close>Delete</button>
</AlertDialog>
<button type="button" class="btn" onclick={() => (open = true)}>Open</button> <script setup>
import { ref } from 'vue';
import AlertDialog from '@/components/rizzo/AlertDialog.vue';
import Button from '@/components/rizzo/Button.vue';
</script>
<template>
<Button variant="error" @click="open = true">Delete</Button>
<AlertDialog
v-model:open="open"
title="Delete item?"
description="This action cannot be undone."
>
<template #actions>
<Button variant="outline" @click="open = false">Cancel</Button>
<Button variant="error" @click="open = false">Delete</Button>
</template>
</AlertDialog>
</template> import { useState } from 'react';
import { AlertDialog, Button } from './components/react';
const [open, setOpen] = useState(false);
<Button variant="error" onClick={() => setOpen(true)}>Delete</Button>
<AlertDialog open={open} onOpenChange={setOpen} title="Delete item?" description="This action cannot be undone."
actions={<><Button variant="outline" onClick={() => setOpen(false)}>Cancel</Button><Button variant="error" onClick={() => setOpen(false)}>Delete</Button></>}
/> Other frameworks: Vanilla · Svelte · Vue · React