Skip to content

shadcn.io is an independent project built on shadcn/ui

Free

Confirmation with Short Content Alert Dialog for Svelte

A short confirmation titled Mark as Complete, with one sentence of description and the buttons Cancel and Confirm.

UI library: Ark UI

The description is one sentence: the task will be marked completed. Cancel and Confirm are the only actions. The task is not updated.

Keep it this short when the outcome is obvious and easy to undo. If it cannot be undone, say so on a destructive Button. In Svelte, Ark UI does not mark the task complete.

Preview

Preview width

Installation

MCP · Pro
Make your AI a shadcn expert
Your agent installs components, builds pages and restyles your app from one prompt, in Claude Code, Cursor or VS Code.
Part of Pro

Anatomy

Alert Dialog anatomy: content, title, description, cancel, action

Usage

<AlertDialog><AlertDialogTrigger>{#snippet asChild(props)}<Button {...props()} variant="outline">Open Dialog</Button>{/snippet}</AlertDialogTrigger><AlertDialogContent><AlertDialogHeader><AlertDialogTitle>Mark as Complete?</AlertDialogTitle><AlertDialogDescription>This task will be marked as completed.</AlertDialogDescription></AlertDialogHeader><AlertDialogFooter><AlertDialogCancel>Cancel</AlertDialogCancel><AlertDialogClose>{#snippet asChild(props)}<AlertDialogAction {...props()}>Confirm</AlertDialogAction>{/snippet}</AlertDialogClose></AlertDialogFooter></AlertDialogContent></AlertDialog>

FAQ

When is a short confirmation enough?

For reversible, low-impact actions like completing a task or changing a preference. Use a detailed confirmation when the action can't be undone and people need context to decide.

Do I still need a description?

Yes. AlertDialogDescription is announced with the title, so even one sentence confirms to screen reader users what they're about to do.

Should I use a toast instead?

Not for confirming. A dialog asks before the action happens; a toast tells people after it did. Many apps do both: confirm first, then a toast that it worked.

Does a short confirmation still need two buttons?

Yes. Someone may have opened it by accident, so keep AlertDialogCancel as an easy way out. Only purely informational alerts get a single button.

How should I write the title?

Two to five words phrased as a question, like Mark as Complete? A question frames the yes or no the buttons answer.

Can people close it without choosing?

Escape closes it and returns focus to the trigger. A click outside does not, so the choice stays explicit.

API Reference

Alert Dialog

Sets props. The rest is on the Alert Dialog page.

Button

Sets props and variant="outline". The rest is on the Button page.