blode
uialert-dialogsource: ok · hit
Alert Dialog
A modal dialog that interrupts the user with important content and expects a response.
npx shadcn add "https://blode.co/ui/r/alert-dialog.json"free
Interaction
modal
Tags auto-generated by rules on 9/24/2026 — empty means no evidence, not lack of support.
Dependencies
Bundle weight · lightui-primitives@base-ui/react
Registry dependencies
button
Files1 · source cached 10/8/2026, 10:50:00 PM
ui/alert-dialog.tsx
"use client";
import { AlertDialog as AlertDialogPrimitive } from "@base-ui/react/alert-dialog";
import * as React from "react";
import { cn } from "@/lib/utils";
import { Button } from "@/components/ui/button";
const AlertDialog = ({ ...props }: AlertDialogPrimitive.Root.Props) => (
<AlertDialogPrimitive.Root data-slot="alert-dialog" {...props} />
);
const AlertDialogTrigger = ({
asChild,
children,
...props
}: AlertDialogPrimitive.Trigger.Props & {
asChild?: boolean;
}) => {
if (asChild && React.isValidElement(children)) {
return (
<AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" render={children} {...props} />
);
}
return (
<AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props}>
{children}
</AlertDialogPrimitive.Trigger>
);
};
const AlertDialogPortal = ({ ...props }: AlertDialogPrimitive.Portal.Props) => (
<AlertDialogPrimitive.Portal data-slot="alert-dialog-portal" {...props} />
);
const AlertDialogOverlay = ({ className, ...props }: AlertDialogPrimitive.Backdrop.Props) => (
<AlertDialogPrimitive.Backdrop
className={cn(
"data-closed:fade-out-0 data-open:fade-in-0 fixed inset-0 z-110 bg-overlay backdrop-blur-[10px] data-closed:animate-out data-open:animate-in duration-200 motion-reduce:transition-none",
className,
)}
data-slot="alert-dialog-overlay"
{...props}
/>
);
const AlertDialogContent = ({
className,
size = "default",
...props
}: AlertDialogPrimitive.Popup.Props & {
size?: "default" | "sm";
}) => (
<AlertDialogPortal>
<AlertDialogOverlay />
<AlertDialogPrimitive.Popup
className={cn(
"group/alert-dialog-content data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 fixed top-[50%] left-[50%] z-110 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-2xl border bg-background p-6 shadow-lg duration-200 data-[size=sm]:max-w-xs data-closed:animate-out data-open:animate-in data-[size=default]:sm:max-w-lg md:w-full",
className,
)}
data-size={size}
data-slot="alert-dialog-content"
{...props}
/>
</AlertDialogPortal>
);
const AlertDialogHeader = ({ className, ...props }: React.ComponentProps<"div">) => (
<div
className={cn(
"grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",
className,
)}
data-slot="alert-dialog-header"
{...props}
/>
);
const AlertDialogFooter = ({ className, ...props }: React.ComponentProps<"div">) => (
<div
className={cn(
"flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",
className,
)}
data-slot="alert-dialog-footer"
{...props}
/>
);
const AlertDialogTitle = ({
className,
...props
}: React.ComponentProps<typeof AlertDialogPrimitive.Title>) => (
<AlertDialogPrimitive.Title
className={cn(
"font-semibold text-lg sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",
className,
)}
data-slot="alert-dialog-title"
{...props}
/>
);
const AlertDialogDescription = ({
className,
...props
}: React.ComponentProps<typeof AlertDialogPrimitive.Description>) => (
<AlertDialogPrimitive.Description
className={cn("text-muted-foreground text-sm", className)}
data-slot="alert-dialog-description"
{...props}
/>
);
const AlertDialogMedia = ({ className, ...props }: React.ComponentProps<"div">) => (
<div
className={cn(
"mb-2 inline-flex size-16 items-center justify-center rounded-md bg-muted sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-8",
className,
)}
data-slot="alert-dialog-media"
{...props}
/>
);
const AlertDialogAction = ({
className,
variant = "default",
size = "default",
...props
}: AlertDialogPrimitive.Close.Props &
Pick<React.ComponentProps<typeof Button>, "variant" | "size">) => (
<AlertDialogPrimitive.Close
className={cn(className)}
data-slot="alert-dialog-action"
render={<Button size={size} variant={variant} />}
{...props}
/>
);
const AlertDialogCancel = ({
className,
variant = "outline",
size = "default",
...props
}: AlertDialogPrimitive.Close.Props &
Pick<React.ComponentProps<typeof Button>, "variant" | "size">) => (
<AlertDialogPrimitive.Close
className={cn(className)}
data-slot="alert-dialog-cancel"
render={<Button size={size} variant={variant} />}
{...props}
/>
);
export {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogMedia,
AlertDialogOverlay,
AlertDialogPortal,
AlertDialogTitle,
AlertDialogTrigger,
};