shadcn.io is not affiliated with official shadcn/ui
Alert Dialog examples · Confirmation
Simple Confirmation Dialog Alert Dialog for React
A simple confirmation dialog with Cancel and Continue.
The basic confirmation: a title, a description of what will happen, and two buttons. This React alert dialog blocks the page until the reader confirms or cancels, which is what you want before deleting an account or any other step that can't be undone. It's shadcn.io's Alert Dialog on Base UI.
Preview
Installation
FAQ
When should I use an Alert Dialog instead of a Dialog?
Use an Alert Dialog for a decision the reader must make, like confirming a deletion. Use a Dialog for forms and content people may close at any time.
Can people dismiss it with Escape or a click outside?
Escape closes it. A click outside doesn't, so the reader has to pick Cancel or Continue.
What's the difference between the two buttons?
AlertDialogCancel is the safe choice, styled as an outline button, and always closes the dialog. AlertDialogAction is the primary button that runs the operation. Keep Cancel first and the action last.
How do I run an async operation on Continue?
Control the dialog's open state, give the action an isLoading state while the request runs, and close the dialog when it settles. Actions with Loading State shows the pattern.
Related
- Simple Delete Confirmation Alert DialogA simple delete confirmation with a
- Simple Information Alert Alert DialogA simple informational dialog with one OK
- Standard DialogA share dialog with a read-only link, a
- Confirmation with Icon Alert DialogA confirmation dialog with a warning icon
- Actions with Icons Alert DialogAn alert dialog whose action carries an
- Confirmation with Centered Icon Alert DialogA confirmation dialog with a large icon