AlertDialog

A controlled confirmation dialog for actions that need explicit user approval — especially destructive ones. Renders a modal with a title, optional description, and confirm/cancel actions.

Installation

npm install @bloomkit/react

Usage

import { AlertDialog } from "@bloomkit/react";
 
const [open, setOpen] = useState(false);
 
<AlertDialog
  open={open}
  onOpenChange={setOpen}
  title="Are you sure?"
  description="This action cannot be undone."
  onConfirm={() => setOpen(false)}
  onCancel={() => setOpen(false)}
/>

Danger variant

Use variant="danger" for destructive actions like deleting data. The confirm button turns red.

<AlertDialog
  open={open}
  onOpenChange={setOpen}
  title="Delete account?"
  description="All your data will be permanently removed. This cannot be undone."
  variant="danger"
  confirmLabel="Delete"
  onConfirm={handleDelete}
  onCancel={() => setOpen(false)}
/>

Props

PropTypeDefaultDescription
openbooleanControlled open state
onOpenChange(open: boolean) => voidCalled when the open state should change
titlestringTitle shown at the top of the dialog. Required — alerts must have a title
descriptionstringOptional secondary description shown under the title
variant"default" | "danger""default"Visual variant of the confirm action. Use danger for destructive confirmations
confirmLabelstring"Confirm"Text on the confirm button
cancelLabelstring"Cancel"Text on the cancel button
onConfirm() => voidCalled when the user confirms
onCancel() => voidCalled when the user cancels
childrenReactNodeOptional custom body between the description and action row
classNamestringExtra Tailwind classes merged onto the dialog content