UIComponentsReact
A dialog that interrupts the reader with something important and waits for an answer.
Built on the headless Alert Dialog.See its API in Docs
Rendered by React 19.3.1
Installation
npx shadcn@4.23.0 add https://hamur.dev/r/react/alert-dialog.jsonIt also adds utils, button. The app needs its setup first: Installation.
Usage
AlertDialog holds AlertDialogTrigger and AlertDialogContent; put AlertDialogHeader (with AlertDialogTitle, AlertDialogDescription and, for an icon, AlertDialogMedia) and AlertDialogFooter (with AlertDialogCancel and AlertDialogAction) inside the content. size="sm" makes the content narrow. The content brings its own portal and overlay in React, Vue, Svelte and Solid; in Angular the template writes uiAlertDialogPortal itself. Unlike a Dialog, a click outside does not close it, and focus moves into it; both come from the headless Alert Dialog.
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogMedia,
AlertDialogOverlay,
AlertDialogPortal,
AlertDialogTitle,
AlertDialogTrigger,
} from '@/components/ui/alert-dialog'Examples
Default
A trigger, a title, a description, and Cancel and Continue.
API reference
The styled parts pass every prop to the headless part they wrap and add classes. The props, data attributes and keyboard are on Alert Dialog's API reference.