Alert Dialog
A modal dialog that interrupts the user with important content and expects a response.
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import { Button, buttonVariants } from "@/components/ui/button";
export default function AlertDialog1() {
return (
<AlertDialog>
<AlertDialogTrigger asChild>
<Button>Show Alert Dialog</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Delete Account?</AlertDialogTitle>
<AlertDialogDescription>
Deleting your account is irreversible and will erase all your data.
This action cannot be undone.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction
className={buttonVariants({ variant: "destructive" })}
>
Continue
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import { Button, buttonVariants } from "@/components/ui/button";
import { Trash } from "@mynaui/icons-react";
export default function AlertDialog2() {
return (
<AlertDialog>
<AlertDialogTrigger asChild>
<Button>Show Icon Dialog</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader className="mb-4 items-center gap-2 md:flex-row md:items-start md:gap-4">
<div
aria-hidden="true"
className="shrink-0 rounded-full bg-red-50 p-3 dark:bg-red-900"
>
<Trash className="size-6 text-red-600 dark:text-red-200" />
</div>
<div className="flex flex-col gap-2">
<AlertDialogTitle>Delete Account?</AlertDialogTitle>
<AlertDialogDescription>
Deleting your account is irreversible and will erase all your
data. This action cannot be undone.
</AlertDialogDescription>
</div>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction
className={buttonVariants({ variant: "destructive" })}
>
Continue
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import { Button, buttonVariants } from "@/components/ui/button";
import { Trash } from "@mynaui/icons-react";
export default function AlertDialog3() {
return (
<AlertDialog>
<AlertDialogTrigger asChild>
<Button>Show Centered Dialog</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader className="mb-4 items-center gap-2">
<div
aria-hidden="true"
className="shrink-0 rounded-full bg-red-50 p-3 dark:bg-red-900"
>
<Trash className="size-6 text-red-600 dark:text-red-200" />
</div>
<div className="flex flex-col gap-2 text-center">
<AlertDialogTitle>Delete Account?</AlertDialogTitle>
<AlertDialogDescription className="text-balance">
Deleting your account is irreversible and will erase all your
data. This action cannot be undone.
</AlertDialogDescription>
</div>
</AlertDialogHeader>
<AlertDialogFooter className="sm:justify-between">
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction
className={buttonVariants({ variant: "destructive" })}
>
Continue
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}
import {
AlertDialog,
AlertDialogAction,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/button";
import { CheckCircle } from "@mynaui/icons-react";
export default function AlertDialog4() {
return (
<AlertDialog>
<AlertDialogTrigger asChild>
<Button variant="outline">Show Success Message</Button>
</AlertDialogTrigger>
<AlertDialogContent className="max-w-[360px]">
<AlertDialogHeader>
<div className="mx-auto mb-4 flex size-12 items-center justify-center rounded-full bg-green-50">
<CheckCircle className="size-6 text-green-600" />
</div>
<AlertDialogTitle className="text-center">
Password Reset Email Sent
</AlertDialogTitle>
<AlertDialogDescription className="text-center">
<span>
We've sent a password reset link to your email address
(praveen@example.com) Please check your inbox and follow the
instructions.
</span>
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter className="sm:justify-center">
<AlertDialogAction>Okay</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}
import {
AlertDialog,
AlertDialogAction,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/button";
import { DangerTriangle } from "@mynaui/icons-react";
export default function AlertDialog5() {
return (
<AlertDialog>
<AlertDialogTrigger asChild>
<Button variant="outline">Show Error Message</Button>
</AlertDialogTrigger>
<AlertDialogContent className="max-w-[360px]">
<AlertDialogHeader>
<div className="mx-auto mb-4 flex size-12 items-center justify-center rounded-full bg-red-50">
<DangerTriangle className="size-6 text-red-600" />
</div>
<AlertDialogTitle className="text-center">
Invalid Email Address
</AlertDialogTitle>
<AlertDialogDescription className="text-center">
<span>
Please enter a valid email address in the format name@example.com.
</span>
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter className="sm:justify-center">
<AlertDialogAction>Okay</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}