Skip to content
Logic2BUI

Search docs

Search components and documentation

New
Menu

Alert Dialog

A modal dialog that interrupts the user with important content and expects a response.

Installation

npx logic2b@next add 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.
      </AlertDialogDescription>
    </AlertDialogHeader>
    <AlertDialogFooter>
      <AlertDialogCancel>Cancel</AlertDialogCancel>
      <AlertDialogAction>Continue</AlertDialogAction>
    </AlertDialogFooter>
  </AlertDialogContent>
</AlertDialog>

Usage notes

AlertDialogAction and AlertDialogCancel render with the default and outline button variants respectively — pass className to restyle (e.g. a destructive action).

Examples

Destructive action

Style the confirm button as destructive for irreversible operations.

Controlled

Open the dialog from your own state with open and onOpenChange.

Accessibility

  • Follows the WAI-ARIA Alert Dialog pattern and traps focus while open.
  • Opening moves focus to the dialog; closing returns it to the trigger.
  • Escape closes the dialog and fires AlertDialogCancel. Unlike a plain dialog, clicking the overlay does not dismiss it — a response is required.
  • The content is labelled by AlertDialogTitle and described by AlertDialogDescription.

Live playground

Edit the component props and inspect the exact JSX before copying it. The preview loads only when this section enters the viewport.

Generated JSX
<AlertDialog>
  <AlertDialogTrigger
    className="rounded-md border px-4 py-2 text-sm font-medium"
  >Delete release</AlertDialogTrigger>
  <AlertDialogContent>
    <AlertDialogHeader>
      <AlertDialogTitle>Delete this release?</AlertDialogTitle>
      <AlertDialogDescription>This action permanently removes the release artifacts.</AlertDialogDescription>
    </AlertDialogHeader>
    <AlertDialogFooter>
      <AlertDialogCancel>Cancel</AlertDialogCancel>
      <AlertDialogAction>Delete</AlertDialogAction>
    </AlertDialogFooter>
  </AlertDialogContent>
</AlertDialog>

API reference

Generated from the public TypeScript exports in src/ui/alert-dialog.tsx.

View JSON

AlertDialog

Component
Props: React.ComponentProps<typeof AlertDialogPrimitive.Root>

AlertDialogPortal

Component
Props: React.ComponentProps<typeof AlertDialogPrimitive.Portal>

AlertDialogOverlay

Component
Props: React.ComponentProps<typeof AlertDialogPrimitive.Overlay>

AlertDialogTrigger

Component
Props: React.ComponentProps<typeof AlertDialogPrimitive.Trigger>

AlertDialogContent

Component
Props: React.ComponentProps<typeof AlertDialogPrimitive.Content>

AlertDialogHeader

Component
Props: React.ComponentProps<"div">

AlertDialogFooter

Component
Props: React.ComponentProps<"div">

AlertDialogTitle

Component
Props: React.ComponentProps<typeof AlertDialogPrimitive.Title>

AlertDialogDescription

Component
Props: React.ComponentProps<typeof AlertDialogPrimitive.Description>

AlertDialogAction

Component
Props: React.ComponentProps<typeof AlertDialogPrimitive.Action>

AlertDialogCancel

Component
Props: React.ComponentProps<typeof AlertDialogPrimitive.Cancel>

Accessibility contract

Machine-readable behavior and consumer responsibilities for alert-dialog.

View JSON
Support
Primitive-managed
Pattern
alertdialog
Radix Alert Dialog
Keyboard interactions for alert-dialog
KeysBehavior
EscapeClose the open surface and restore focus.
Tab Shift+TabMove between confirmation actions.

Built-in semantics

  • Uses alertdialog semantics, traps focus and requires an explicit action.

Consumer responsibilities

  • Describe the consequence and give destructive/escape actions unambiguous labels.