Base components
Alert Dialog
A modal dialog for critical confirmations or destructive actions. Requires explicit dismissal (button or Escape); cannot be closed by clicking outside. Built with Ark UI Dialog (role="alertdialog") and Ocean UI design tokens.
Example
Are you absolutely sure?
This action cannot be undone. This will permanently delete your account and remove your data from our servers.
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/alert-dialog";
export default function AlertDialogDemo() {
return (
<AlertDialog>
<AlertDialogTrigger asChild>
<Button variant="outline">Show Dialog</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
<AlertDialogDescription>
This action cannot be undone. This will permanently delete your
account and remove your data from our servers.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction>Continue</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/alert-dialog";
export default function AlertDialogDemo() {
return (
<AlertDialog>
<AlertDialogTrigger
asChild={(triggerProps) => (
<Button {...triggerProps} variant="outline">
Show Dialog
</Button>
)}
/>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
<AlertDialogDescription>
This action cannot be undone. This will permanently delete your
account and remove your data from our servers.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction>Continue</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}
Vue support is coming soon
Svelte support is coming soon
How to install and use
1
Complete the manual installation setup
If you haven't already completed the first 4 steps of the manual installation guide, please do so before continuing to install these components.
2
Create a alert-dialog.tsx file and paste the following code into it.
/components/ui/alert-dialog.tsx
import { Dialog } from "@ark-ui/react/dialog";
import type { ComponentProps } from "react";
import { cn } from "@/lib/utils";
import { buttonVariants } from "@/components/ui/alert-dialog";
function AlertDialogRoot(
props: ComponentProps<typeof Dialog.Root>
) {
return (
<Dialog.Root
data-slot="alert-dialog"
role="alertdialog"
closeOnInteractOutside={false}
{...props}
/>
);
}
function AlertDialogTrigger(
props: ComponentProps<typeof Dialog.Trigger>
) {
return (
<Dialog.Trigger
data-slot="alert-dialog-trigger"
asChild
{...props}
/>
);
}
function AlertDialogBackdrop({
className,
...props
}: ComponentProps<typeof Dialog.Backdrop>) {
return (
<Dialog.Backdrop
data-slot="alert-dialog-overlay"
className={cn(
"fixed inset-0 z-50 bg-black/50",
"data-[state=open]:animate-in data-[state=open]:fade-in-0",
"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:duration-200",
className
)}
{...props}
/>
);
}
function AlertDialogContent({
className,
children,
...props
}: ComponentProps<typeof Dialog.Content>) {
return (
<>
<AlertDialogBackdrop />
<Dialog.Positioner
data-slot="alert-dialog-positioner"
className="fixed inset-0 z-50 flex items-center justify-center p-4"
>
<Dialog.Content
data-slot="alert-dialog-content"
className={cn(
"bg-background grid w-full max-w-[calc(100%-2rem)] gap-4 rounded-lg border p-6 shadow-lg sm:max-w-lg",
"data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:duration-200",
"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:duration-200",
className
)}
{...props}
>
{children}
</Dialog.Content>
</Dialog.Positioner>
</>
);
}
function AlertDialogHeader({
className,
...props
}: ComponentProps<"div">) {
return (
<div
data-slot="alert-dialog-header"
className={cn(
"flex flex-col gap-2 text-center sm:text-left",
className
)}
{...props}
/>
);
}
function AlertDialogFooter({
className,
...props
}: ComponentProps<"div">) {
return (
<div
data-slot="alert-dialog-footer"
className={cn(
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
className
)}
{...props}
/>
);
}
function AlertDialogTitle({
className,
...props
}: ComponentProps<typeof Dialog.Title>) {
return (
<Dialog.Title
data-slot="alert-dialog-title"
className={cn("text-lg font-semibold", className)}
{...props}
/>
);
}
function AlertDialogDescription({
className,
...props
}: ComponentProps<typeof Dialog.Description>) {
return (
<Dialog.Description
data-slot="alert-dialog-description"
className={cn("text-muted-foreground text-sm", className)}
{...props}
/>
);
}
function AlertDialogAction({
className,
...props
}: ComponentProps<typeof Dialog.CloseTrigger>) {
return (
<Dialog.CloseTrigger
className={cn(buttonVariants(), className)}
{...props}
/>
);
}
function AlertDialogCancel({
className,
...props
}: ComponentProps<typeof Dialog.CloseTrigger>) {
return (
<Dialog.CloseTrigger
className={cn(buttonVariants({ variant: "outline" }), className)}
{...props}
/>
);
}
/**
* Unstyled close trigger for custom close buttons (e.g. X icon in header).
* Style with buttonVariants({ variant: "outline", size: "icon" }) as needed.
*/
function AlertDialogCloseTrigger({
className,
...props
}: ComponentProps<typeof Dialog.CloseTrigger>) {
return (
<Dialog.CloseTrigger
data-slot="alert-dialog-close-trigger"
className={className}
{...props}
/>
);
}
export {
AlertDialogRoot as AlertDialog,
AlertDialogTrigger,
AlertDialogBackdrop,
AlertDialogContent,
AlertDialogHeader,
AlertDialogFooter,
AlertDialogTitle,
AlertDialogDescription,
AlertDialogAction,
AlertDialogCancel,
AlertDialogCloseTrigger,
};
/components/ui/alert-dialog.tsx
import { Dialog } from "@ark-ui/solid/dialog";
import type { ComponentProps, ParentComponent } from "solid-js";
import { splitProps } from "solid-js";
import { cn } from "@/lib/utils";
import { buttonVariants } from "./button";
export interface AlertDialogProps extends ComponentProps<typeof Dialog.Root> {}
export const AlertDialog: ParentComponent<AlertDialogProps> = (props) => {
return (
<Dialog.Root
data-slot="alert-dialog"
role="alertdialog"
closeOnInteractOutside={false}
{...props}
/>
);
};
export interface AlertDialogTriggerProps
extends ComponentProps<typeof Dialog.Trigger> {}
export const AlertDialogTrigger: ParentComponent<AlertDialogTriggerProps> = (
props
) => {
return (
<Dialog.Trigger data-slot="alert-dialog-trigger" {...props} />
);
};
export interface AlertDialogBackdropProps
extends ComponentProps<typeof Dialog.Backdrop> {}
export const AlertDialogBackdrop: ParentComponent<AlertDialogBackdropProps> = (
props
) => {
const [local, rest] = splitProps(props, ["class"]);
return (
<Dialog.Backdrop
data-slot="alert-dialog-overlay"
class={cn(
"fixed inset-0 z-50 bg-black/50",
"data-[state=open]:animate-in data-[state=open]:fade-in-0",
"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:duration-200",
local.class
)}
{...rest}
/>
);
};
export interface AlertDialogContentProps
extends ComponentProps<typeof Dialog.Content> {}
export const AlertDialogContent: ParentComponent<AlertDialogContentProps> = (
props
) => {
const [local, rest] = splitProps(props, ["class", "children"]);
return (
<>
<AlertDialogBackdrop />
<Dialog.Positioner
data-slot="alert-dialog-positioner"
class="fixed inset-0 z-50 flex items-center justify-center p-4"
>
<Dialog.Content
data-slot="alert-dialog-content"
class={cn(
"bg-background grid w-full max-w-[calc(100%-2rem)] gap-4 rounded-lg border p-6 shadow-lg sm:max-w-lg",
"data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:duration-200",
"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:duration-200",
local.class
)}
{...rest}
>
{local.children}
</Dialog.Content>
</Dialog.Positioner>
</>
);
};
export interface AlertDialogHeaderProps extends ComponentProps<"div"> {}
export const AlertDialogHeader: ParentComponent<AlertDialogHeaderProps> = (
props
) => {
const [local, rest] = splitProps(props, ["class"]);
return (
<div
data-slot="alert-dialog-header"
class={cn(
"flex flex-col gap-2 text-center sm:text-left",
local.class
)}
{...rest}
/>
);
};
export interface AlertDialogFooterProps extends ComponentProps<"div"> {}
export const AlertDialogFooter: ParentComponent<AlertDialogFooterProps> = (
props
) => {
const [local, rest] = splitProps(props, ["class"]);
return (
<div
data-slot="alert-dialog-footer"
class={cn(
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
local.class
)}
{...rest}
/>
);
};
export interface AlertDialogTitleProps
extends ComponentProps<typeof Dialog.Title> {}
export const AlertDialogTitle: ParentComponent<AlertDialogTitleProps> = (
props
) => {
const [local, rest] = splitProps(props, ["class"]);
return (
<Dialog.Title
data-slot="alert-dialog-title"
class={cn("text-lg font-semibold", local.class)}
{...rest}
/>
);
};
export interface AlertDialogDescriptionProps
extends ComponentProps<typeof Dialog.Description> {}
export const AlertDialogDescription: ParentComponent<
AlertDialogDescriptionProps
> = (props) => {
const [local, rest] = splitProps(props, ["class"]);
return (
<Dialog.Description
data-slot="alert-dialog-description"
class={cn("text-muted-foreground text-sm", local.class)}
{...rest}
/>
);
};
export interface AlertDialogActionProps
extends ComponentProps<typeof Dialog.CloseTrigger> {}
export const AlertDialogAction: ParentComponent<AlertDialogActionProps> = (
props
) => {
const [local, rest] = splitProps(props, ["class"]);
return (
<Dialog.CloseTrigger
class={cn(buttonVariants(), local.class)}
{...rest}
/>
);
};
export interface AlertDialogCancelProps
extends ComponentProps<typeof Dialog.CloseTrigger> {}
export const AlertDialogCancel: ParentComponent<AlertDialogCancelProps> = (
props
) => {
const [local, rest] = splitProps(props, ["class"]);
return (
<Dialog.CloseTrigger
class={cn(buttonVariants({ variant: "outline" }), local.class)}
{...rest}
/>
);
}
/**
* Unstyled close trigger for custom close buttons (e.g. X icon in header).
* Style with buttonVariants({ variant: "outline", size: "icon" }) as needed.
*/
export interface AlertDialogCloseTriggerProps
extends ComponentProps<typeof Dialog.CloseTrigger> {}
export const AlertDialogCloseTrigger: ParentComponent<
AlertDialogCloseTriggerProps
> = (props) => {
return (
<Dialog.CloseTrigger
data-slot="alert-dialog-close-trigger"
{...props}
/>
);
};
/components/ui/alert-dialog.tsx
import { Dialog } from "@ark-ui/react/dialog";
import type { ComponentProps } from "react";
import { cn } from "@/lib/utils";
import { buttonVariants } from "@/components/ui/alert-dialog";
function AlertDialogRoot(
props: ComponentProps<typeof Dialog.Root>
) {
return (
<Dialog.Root
data-slot="alert-dialog"
role="alertdialog"
closeOnInteractOutside={false}
{...props}
/>
);
}
function AlertDialogTrigger(
props: ComponentProps<typeof Dialog.Trigger>
) {
return (
<Dialog.Trigger
data-slot="alert-dialog-trigger"
asChild
{...props}
/>
);
}
function AlertDialogBackdrop({
className,
...props
}: ComponentProps<typeof Dialog.Backdrop>) {
return (
<Dialog.Backdrop
data-slot="alert-dialog-overlay"
className={cn(
"fixed inset-0 z-50 bg-black/50",
"data-[state=open]:animate-in data-[state=open]:fade-in-0",
"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:duration-200",
className
)}
{...props}
/>
);
}
function AlertDialogContent({
className,
children,
...props
}: ComponentProps<typeof Dialog.Content>) {
return (
<>
<AlertDialogBackdrop />
<Dialog.Positioner
data-slot="alert-dialog-positioner"
className="fixed inset-0 z-50 flex items-center justify-center p-4"
>
<Dialog.Content
data-slot="alert-dialog-content"
className={cn(
"bg-background grid w-full max-w-[calc(100%-2rem)] gap-4 rounded-lg border p-6 shadow-lg sm:max-w-lg",
"data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:duration-200",
"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:duration-200",
className
)}
{...props}
>
{children}
</Dialog.Content>
</Dialog.Positioner>
</>
);
}
function AlertDialogHeader({
className,
...props
}: ComponentProps<"div">) {
return (
<div
data-slot="alert-dialog-header"
className={cn(
"flex flex-col gap-2 text-center sm:text-left",
className
)}
{...props}
/>
);
}
function AlertDialogFooter({
className,
...props
}: ComponentProps<"div">) {
return (
<div
data-slot="alert-dialog-footer"
className={cn(
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
className
)}
{...props}
/>
);
}
function AlertDialogTitle({
className,
...props
}: ComponentProps<typeof Dialog.Title>) {
return (
<Dialog.Title
data-slot="alert-dialog-title"
className={cn("text-lg font-semibold", className)}
{...props}
/>
);
}
function AlertDialogDescription({
className,
...props
}: ComponentProps<typeof Dialog.Description>) {
return (
<Dialog.Description
data-slot="alert-dialog-description"
className={cn("text-muted-foreground text-sm", className)}
{...props}
/>
);
}
function AlertDialogAction({
className,
...props
}: ComponentProps<typeof Dialog.CloseTrigger>) {
return (
<Dialog.CloseTrigger
className={cn(buttonVariants(), className)}
{...props}
/>
);
}
function AlertDialogCancel({
className,
...props
}: ComponentProps<typeof Dialog.CloseTrigger>) {
return (
<Dialog.CloseTrigger
className={cn(buttonVariants({ variant: "outline" }), className)}
{...props}
/>
);
}
/**
* Unstyled close trigger for custom close buttons (e.g. X icon in header).
* Style with buttonVariants({ variant: "outline", size: "icon" }) as needed.
*/
function AlertDialogCloseTrigger({
className,
...props
}: ComponentProps<typeof Dialog.CloseTrigger>) {
return (
<Dialog.CloseTrigger
data-slot="alert-dialog-close-trigger"
className={className}
{...props}
/>
);
}
export {
AlertDialogRoot as AlertDialog,
AlertDialogTrigger,
AlertDialogBackdrop,
AlertDialogContent,
AlertDialogHeader,
AlertDialogFooter,
AlertDialogTitle,
AlertDialogDescription,
AlertDialogAction,
AlertDialogCancel,
AlertDialogCloseTrigger,
};
/components/ui/alert-dialog.tsx
import { Dialog } from "@ark-ui/react/dialog";
import type { ComponentProps } from "react";
import { cn } from "@/lib/utils";
import { buttonVariants } from "@/components/ui/alert-dialog";
function AlertDialogRoot(
props: ComponentProps<typeof Dialog.Root>
) {
return (
<Dialog.Root
data-slot="alert-dialog"
role="alertdialog"
closeOnInteractOutside={false}
{...props}
/>
);
}
function AlertDialogTrigger(
props: ComponentProps<typeof Dialog.Trigger>
) {
return (
<Dialog.Trigger
data-slot="alert-dialog-trigger"
asChild
{...props}
/>
);
}
function AlertDialogBackdrop({
className,
...props
}: ComponentProps<typeof Dialog.Backdrop>) {
return (
<Dialog.Backdrop
data-slot="alert-dialog-overlay"
className={cn(
"fixed inset-0 z-50 bg-black/50",
"data-[state=open]:animate-in data-[state=open]:fade-in-0",
"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:duration-200",
className
)}
{...props}
/>
);
}
function AlertDialogContent({
className,
children,
...props
}: ComponentProps<typeof Dialog.Content>) {
return (
<>
<AlertDialogBackdrop />
<Dialog.Positioner
data-slot="alert-dialog-positioner"
className="fixed inset-0 z-50 flex items-center justify-center p-4"
>
<Dialog.Content
data-slot="alert-dialog-content"
className={cn(
"bg-background grid w-full max-w-[calc(100%-2rem)] gap-4 rounded-lg border p-6 shadow-lg sm:max-w-lg",
"data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:duration-200",
"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:duration-200",
className
)}
{...props}
>
{children}
</Dialog.Content>
</Dialog.Positioner>
</>
);
}
function AlertDialogHeader({
className,
...props
}: ComponentProps<"div">) {
return (
<div
data-slot="alert-dialog-header"
className={cn(
"flex flex-col gap-2 text-center sm:text-left",
className
)}
{...props}
/>
);
}
function AlertDialogFooter({
className,
...props
}: ComponentProps<"div">) {
return (
<div
data-slot="alert-dialog-footer"
className={cn(
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
className
)}
{...props}
/>
);
}
function AlertDialogTitle({
className,
...props
}: ComponentProps<typeof Dialog.Title>) {
return (
<Dialog.Title
data-slot="alert-dialog-title"
className={cn("text-lg font-semibold", className)}
{...props}
/>
);
}
function AlertDialogDescription({
className,
...props
}: ComponentProps<typeof Dialog.Description>) {
return (
<Dialog.Description
data-slot="alert-dialog-description"
className={cn("text-muted-foreground text-sm", className)}
{...props}
/>
);
}
function AlertDialogAction({
className,
...props
}: ComponentProps<typeof Dialog.CloseTrigger>) {
return (
<Dialog.CloseTrigger
className={cn(buttonVariants(), className)}
{...props}
/>
);
}
function AlertDialogCancel({
className,
...props
}: ComponentProps<typeof Dialog.CloseTrigger>) {
return (
<Dialog.CloseTrigger
className={cn(buttonVariants({ variant: "outline" }), className)}
{...props}
/>
);
}
/**
* Unstyled close trigger for custom close buttons (e.g. X icon in header).
* Style with buttonVariants({ variant: "outline", size: "icon" }) as needed.
*/
function AlertDialogCloseTrigger({
className,
...props
}: ComponentProps<typeof Dialog.CloseTrigger>) {
return (
<Dialog.CloseTrigger
data-slot="alert-dialog-close-trigger"
className={className}
{...props}
/>
);
}
export {
AlertDialogRoot as AlertDialog,
AlertDialogTrigger,
AlertDialogBackdrop,
AlertDialogContent,
AlertDialogHeader,
AlertDialogFooter,
AlertDialogTitle,
AlertDialogDescription,
AlertDialogAction,
AlertDialogCancel,
AlertDialogCloseTrigger,
};
3
Finally, Choose any example you like and add it to your project.
For instance, create a new file at components/shared/{example-component-name}.tsx, paste the example code into that file, and then import and use the component wherever you need it in your application.
The Alert Dialog uses Ark UI's Dialog with role="alertdialog" and
closeOnInteractOutside={false} for alert semantics. It is styled with
Tailwind CSS and Ocean UI design tokens.
Examples
With Icon
Are you absolutely sure?
This action cannot be undone. This will permanently delete your account and remove your data from our servers.
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/alert-dialog";
import { OctagonAlert } from "lucide-react";
export default function AlertDialogWithIcon() {
return (
<AlertDialog>
<AlertDialogTrigger asChild>
<Button variant="outline">Show Dialog</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<div className="flex flex-col gap-3 sm:flex-row sm:items-start">
<OctagonAlert className="size-5 shrink-0 mt-1" />
<div className="flex flex-col gap-1">
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
<AlertDialogDescription>
This action cannot be undone. This will permanently delete your
account and remove your data from our servers.
</AlertDialogDescription>
</div>
</div>
</AlertDialogHeader>
<AlertDialogFooter className="mt-2">
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction>Continue</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/alert-dialog";
import { OctagonAlert } from "lucide-solid";
export default function AlertDialogWithIcon() {
return (
<AlertDialog>
<AlertDialogTrigger
asChild={(triggerProps) => (
<Button {...triggerProps} variant="outline">
Show Dialog
</Button>
)}
/>
<AlertDialogContent>
<AlertDialogHeader>
<div class="flex flex-col gap-3 sm:flex-row sm:items-start">
<OctagonAlert class="size-5 shrink-0 mt-1" />
<div class="flex flex-col gap-1">
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
<AlertDialogDescription>
This action cannot be undone. This will permanently delete your
account and remove your data from our servers.
</AlertDialogDescription>
</div>
</div>
</AlertDialogHeader>
<AlertDialogFooter class="mt-2">
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction>Continue</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}
Vue support is coming soon
Svelte support is coming soon
Destructive
Are you absolutely sure?
This action cannot be undone. This will permanently delete your account and remove your data from our servers.
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import {
Button,
buttonVariants,
} from "@/components/ui/alert-dialog";
import { OctagonAlert } from "lucide-react";
export default function AlertDialogDestructive() {
return (
<AlertDialog>
<AlertDialogTrigger asChild>
<Button variant="outline">Show Dialog</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader className="rounded-none">
<div className="flex flex-col gap-3 sm:flex-row sm:items-start">
<OctagonAlert className="size-5 shrink-0 mt-1 text-destructive fill-destructive/10" />
<div className="flex flex-col gap-1">
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
<AlertDialogDescription>
This action cannot be undone. This will permanently delete your
account and remove your data from our servers.
</AlertDialogDescription>
</div>
</div>
</AlertDialogHeader>
<AlertDialogFooter className="mt-2">
<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/alert-dialog";
import { OctagonAlert } from "lucide-solid";
export default function AlertDialogDestructive() {
return (
<AlertDialog>
<AlertDialogTrigger
asChild={(triggerProps) => (
<Button {...triggerProps} variant="outline">
Show Dialog
</Button>
)}
/>
<AlertDialogContent>
<AlertDialogHeader class="rounded-none">
<div class="flex flex-col gap-3 sm:flex-row sm:items-start">
<OctagonAlert class="size-5 shrink-0 mt-1 text-destructive fill-destructive/10" />
<div class="flex flex-col gap-1">
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
<AlertDialogDescription>
This action cannot be undone. This will permanently delete your
account and remove your data from our servers.
</AlertDialogDescription>
</div>
</div>
</AlertDialogHeader>
<AlertDialogFooter class="mt-2">
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction
class={buttonVariants({ variant: "destructive" })}
>
Continue
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}
Vue support is coming soon
Svelte support is coming soon
With Header
Are you absolutely sure?
This action cannot be undone. This will permanently delete your account and remove your data from our servers.
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import {
Button,
buttonVariants,
} from "@/components/ui/alert-dialog";
import { OctagonAlert } from "lucide-react";
export default function AlertDialogHeaderDemo() {
return (
<AlertDialog>
<AlertDialogTrigger asChild>
<Button variant="outline">Show Dialog</Button>
</AlertDialogTrigger>
<AlertDialogContent className="pt-2">
<AlertDialogHeader className="rounded-none">
<div className="flex flex-col gap-3">
<div className="flex items-center gap-3 border-b py-3">
<OctagonAlert className="size-5 shrink-0 text-destructive fill-destructive/10" />
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
</div>
<AlertDialogDescription className="py-3">
This action cannot be undone. This will permanently delete your
account and remove your data from our servers.
</AlertDialogDescription>
</div>
</AlertDialogHeader>
<AlertDialogFooter className="mt-2">
<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/alert-dialog";
import { OctagonAlert } from "lucide-solid";
export default function AlertDialogHeaderDemo() {
return (
<AlertDialog>
<AlertDialogTrigger
asChild={(triggerProps) => (
<Button {...triggerProps} variant="outline">
Show Dialog
</Button>
)}
/>
<AlertDialogContent class="pt-2">
<AlertDialogHeader class="rounded-none">
<div class="flex flex-col gap-3">
<div class="flex items-center gap-3 border-b py-3">
<OctagonAlert class="size-5 shrink-0 text-destructive fill-destructive/10" />
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
</div>
<AlertDialogDescription class="py-3">
This action cannot be undone. This will permanently delete your
account and remove your data from our servers.
</AlertDialogDescription>
</div>
</AlertDialogHeader>
<AlertDialogFooter class="mt-2">
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction
class={buttonVariants({ variant: "destructive" })}
>
Continue
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}
Vue support is coming soon
Svelte support is coming soon
With Close Button
Are you absolutely sure?
This action cannot be undone. This will permanently delete your account and remove your data from our servers.
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogCloseTrigger,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import {
Button,
buttonVariants,
} from "@/components/ui/alert-dialog";
import { cn } from "@/lib/utils";
import { OctagonAlert, XIcon } from "lucide-react";
export default function AlertDialogWithCloseButton() {
return (
<AlertDialog>
<AlertDialogTrigger asChild>
<Button variant="outline">Show Dialog</Button>
</AlertDialogTrigger>
<AlertDialogContent className="pt-2">
<AlertDialogHeader className="rounded-none">
<div className="flex flex-col gap-3">
<div className="flex items-center justify-between gap-3 border-b py-3">
<div className="flex items-center gap-3">
<OctagonAlert className="size-5 shrink-0 text-destructive fill-destructive/10" />
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
</div>
<AlertDialogCloseTrigger
className={cn(
buttonVariants({ variant: "outline", size: "sm" }),
"size-8 p-0 [&_svg]:size-3.5"
)}
aria-label="Close dialog"
>
<XIcon />
</AlertDialogCloseTrigger>
</div>
<AlertDialogDescription className="py-3">
This action cannot be undone. This will permanently delete your
account and remove your data from our servers.
</AlertDialogDescription>
</div>
</AlertDialogHeader>
<AlertDialogFooter className="mt-2">
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction
className={buttonVariants({ variant: "destructive" })}
>
Continue
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogCloseTrigger,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import {
Button,
buttonVariants,
} from "@/components/ui/alert-dialog";
import { cn } from "@/lib/utils";
import { OctagonAlert, XIcon } from "lucide-solid";
export default function AlertDialogWithCloseButton() {
return (
<AlertDialog>
<AlertDialogTrigger
asChild={(triggerProps) => (
<Button {...triggerProps} variant="outline">
Show Dialog
</Button>
)}
/>
<AlertDialogContent class="pt-2">
<AlertDialogHeader class="rounded-none">
<div class="flex flex-col gap-3">
<div class="flex items-center justify-between gap-3 border-b py-3">
<div class="flex items-center gap-3">
<OctagonAlert class="size-5 shrink-0 text-destructive fill-destructive/10" />
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
</div>
<AlertDialogCloseTrigger
class={cn(
buttonVariants({ variant: "outline", size: "sm" }),
"size-8 p-0 [&_svg]:size-3.5"
)}
aria-label="Close dialog"
>
<XIcon />
</AlertDialogCloseTrigger>
</div>
<AlertDialogDescription class="py-3">
This action cannot be undone. This will permanently delete your
account and remove your data from our servers.
</AlertDialogDescription>
</div>
</AlertDialogHeader>
<AlertDialogFooter class="mt-2">
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction
class={buttonVariants({ variant: "destructive" })}
>
Continue
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}
Vue support is coming soon
Svelte support is coming soon