Skip to content

Alert Dialog

A dialog that requires user response to proceed.

API Reference

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.

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.

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

Close Confirmation