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
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add alert-dialog

Or install the full npm package:

npm install bigbullui

Usage

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 helpers

Zero 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 />
PropTypeDescription
openbooleanControls visibility.
onOpenChange(open: boolean) => voidCalled on confirm/cancel/Escape.
titlestringDialog heading.
descriptionstringBody copy under the title.
animatedbooleanDual-mode: false renders instantly with no motion. Default true.
confirmLabelstringAction button label.
cancelLabelstringCancel button label.
destructivebooleanRed destructive confirm styling.
onConfirm() => voidConfirm callback.
onCancel() => voidCancel callback.
childrenReact.ReactNodeChild elements rendered inside the component.
classNamestringOptional Tailwind or custom CSS classes merged with component styles.