- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Attachment
- Autocomplete
- Avatar
- Badge
- Breadcrumb
- Bubble
- Button
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Checkbox Group
- Collapsible
- Combobox
- Command
- Context Menu
- Date Picker
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Fieldset
- Form
- Frame
- Group
- Input
- Input Group
- Kbd
- Label
- Menu
- Menubar
- Message
- Meter
- Number Field
- OTP Field
- Pagination
- Popover
- Preview Card
- Progress
- Questionnaire
- Radio Group
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Toolbar
- Tooltip
- Artifact
- Audio Player
- Canvas
- Chain of Thought
- Checkpoint
- Code Block
- Commit
- Connection
- Context
- Controls
- Edge
- Environment Variables
- Mic Selector
- Model Selector
- Node
- Node Toolbar
- Open in Chat
- Panel
- Plan
- Prompt Input
- Queue
- Reasoning
- Sandbox
- Schema Display
- Shimmer
- Snippet
- Sources
- Speech Input
- Stack Trace
- Suggestion
- Tool
- Transcription
- Web Preview
Alert Dialog
A dialog that requires user response to proceed.
import {
AlertDialog,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/button";
export default function Particle() {
return (
<AlertDialog>
<AlertDialogTrigger render={<Button variant="destructive" />}>
Delete Account
</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 render={<Button variant="ghost" />}>Cancel</AlertDialogCancel>
<AlertDialogCancel render={<Button variant="destructive" />}>
Delete Account
</AlertDialogCancel>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}
Installation
pnpm dlx shadcn@latest add @frontal-labs/alert-dialog
Usage
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";<AlertDialog>
<AlertDialogTrigger>Delete Account</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 variant="destructive">Delete Account</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>API Reference
AlertDialog
Root component. Alias for AlertDialog.Root from Base UI.
AlertDialogTrigger
Trigger button that opens the alert dialog. Alias for AlertDialog.Trigger from Base UI.
AlertDialogContent
Popup container that displays the alert dialog content. Renders the portal and the overlay internally, so AlertDialogPortal and AlertDialogOverlay do not need to be composed by hand.
| Prop | Type | Default | Description |
|---|---|---|---|
size | "default" | "sm" | "default" | Controls the maximum width and the footer layout. sm stays narrow and lays the footer out as two equal columns |
dark | boolean | true | Renders the surface with the dark palette by applying .dark to the portal element |
All other props from AlertDialog.Popup are supported.
The dark prop
The alert dialog renders with the dark palette by default. Pass dark={false} when it should follow the ambient theme instead — next-themes sets dark on <html> and the portal lands in document.body, inside it, so the surface can pick up the ambient theme once dark is turned off.
Reach for it when you want a deliberately inverted surface, or when the alert dialog is opened from a .dark region scoped mid-page, which a portal does escape. For that second case prefer rendering into the scoped node instead, which keeps inheritance intact in both directions.
<AlertDialogContent dark>...</AlertDialogContent>AlertDialogHeader
Container for the alert dialog title and description. Centers its content, switching to a left-aligned layout from the sm breakpoint when size is default.
AlertDialogMedia
Optional icon container placed inside AlertDialogHeader. Renders a muted rounded square that sizes any child SVG.
AlertDialogFooter
Footer section for action buttons. Renders with a top border and a muted background.
Unlike Dialog, alert dialog has no scrollable panel part. Put title and description in AlertDialogHeader, actions in AlertDialogFooter, and use a plain element with className if you need extra body content between them.
Example:
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction variant="destructive">Delete</AlertDialogAction>
</AlertDialogFooter>AlertDialogTitle
Title component. Alias for AlertDialog.Title from Base UI.
AlertDialogDescription
Description component. Alias for AlertDialog.Description from Base UI.
AlertDialogCancel
Dismissing action. Wraps AlertDialog.Close from Base UI and renders it as a Button.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | ButtonProps["variant"] | "outline" | Button variant used for the rendered button |
size | ButtonProps["size"] | "default" | Button size used for the rendered button |
AlertDialogAction
Confirming action. A Button carrying data-slot="alert-dialog-action"; it does not close the dialog on its own, so wire up onClick or compose it with AlertDialogCancel as needed.
AlertDialogPortal
Portal component for rendering outside the DOM hierarchy. Alias for AlertDialog.Portal from Base UI. Rendered internally by AlertDialogContent.
AlertDialogOverlay
Backdrop component. Styled wrapper for AlertDialog.Backdrop from Base UI. Rendered internally by AlertDialogContent.
Examples
Destructive Action
import {
AlertDialog,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/button";
export default function Particle() {
return (
<AlertDialog>
<AlertDialogTrigger render={<Button variant="destructive" />}>
Delete Account
</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 render={<Button variant="ghost" />}>Cancel</AlertDialogCancel>
<AlertDialogCancel render={<Button variant="destructive" />}>
Delete Account
</AlertDialogCancel>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}
Close Confirmation
"use client";
import { useState } from "react";
import {
AlertDialog,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/button";
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog";
import { Field } from "@/components/ui/field";
import { Textarea } from "@/components/ui/textarea";
export default function Particle() {
const [dialogOpen, setDialogOpen] = useState(false);
const [confirmOpen, setConfirmOpen] = useState(false);
const [value, setValue] = useState("");
return (
<Dialog
onOpenChange={(o) => {
if (!o && value) {
setConfirmOpen(true);
} else {
setDialogOpen(o);
}
}}
open={dialogOpen}
>
<DialogTrigger render={<Button variant="outline" />}>Compose</DialogTrigger>
<DialogContent showCloseButton={false}>
<DialogHeader>
<DialogTitle>New message</DialogTitle>
<DialogDescription>Type something and try closing.</DialogDescription>
</DialogHeader>
<form
className="contents"
onSubmit={(event) => {
event.preventDefault();
// Close the dialog when submitting
setDialogOpen(false);
}}
>
<div>
<Field>
<Textarea onChange={(e) => setValue(e.target.value)} value={value} />
</Field>
</div>
<DialogFooter>
<DialogClose render={<Button variant="ghost" />}>Cancel</DialogClose>
<Button
onClick={() => {
setValue("");
setDialogOpen(false);
}}
>
Send
</Button>
</DialogFooter>
</form>
</DialogContent>
{/* Confirmation dialog */}
<AlertDialog onOpenChange={setConfirmOpen} open={confirmOpen}>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Discard changes?</AlertDialogTitle>
<AlertDialogDescription>Your message will be lost.</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel render={<Button variant="ghost" />}>Go back</AlertDialogCancel>
<Button
onClick={() => {
setConfirmOpen(false);
setValue("");
setDialogOpen(false);
}}
>
Discard
</Button>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</Dialog>
);
}
On This Page