Componentfeedback1.83 KB gzipZero dependencies
Alert Dialog
Confirm/cancel modal with destructive variant for irreversible actions, Escape/backdrop close, and animated content.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add alert-dialogOr install the full npm package:
npm install bigbulluiUsage
tsx3 lines
import { AlertDialog } from "@/components/ui/alert-dialog"; <AlertDialog open={open} onOpenChange={setOpen} title="Delete item" description="This cannot be undone." destructive confirmLabel="Delete" onConfirm={doDelete} />Source code
alert-dialog.tsx + 3 helpersZero third-party dependencies (4 local files shown in tabs below).
tsxalert-dialog.tsx276 lines
"use client"; import * as React from "react";import { createPortal } from "react-dom";import { cn } from "./lib/utils";import { getFocusable, hideBackgroundSiblings, lockBodyScroll, registerEscapeLayer, trapFocus,} from "./lib/focus-trap";import { useIsMounted } from "./lib/react-compat"; interface AlertDialogContextValue { titleId: string; descId: string; close: () => void;Props
Interactive Prop Playground
Tweak parsed AST props below to generate ready-to-paste JSX.
tsx3 lines
import { AlertDialogHeader } from "@/components/ui/alert-dialog"; <AlertDialogHeader />| Prop | Type | Description |
|---|---|---|
| open | boolean | Controls visibility. |
| onOpenChange | (open: boolean) => void | Called on confirm/cancel/Escape. |
| title | string | Dialog heading. |
| description | string | Body copy under the title. |
| animated | boolean | Dual-mode: false renders instantly with no motion. Default true. |
| confirmLabel | string | Action button label. |
| cancelLabel | string | Cancel button label. |
| destructive | boolean | Red destructive confirm styling. |
| onConfirm | () => void | Confirm callback. |
| onCancel | () => void | Cancel callback. |
| children | React.ReactNode | Child elements rendered inside the component. |
| className | string | Optional Tailwind or custom CSS classes merged with component styles. |