Componentfeedback1.11 KB gzipZero dependencies
ConfirmDialog
Self-contained confirm dialog with focus trap and stamp entrance for confirm button in destructive mode.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add confirm-dialogOr install the full npm package:
npm install bigbulluiUsage
tsx3 lines
import { ConfirmDialog } from "@/components/ui/confirm-dialog" <ConfirmDialog open={true} onOpenChange={() => {}} title="Delete item" description="Are you sure you want to delete this item?" confirmLabel="Delete" destructive={true} onConfirm={() => {}} onCancel={() => {}} />Source code
confirm-dialog.tsx + 2 helpersZero third-party dependencies (3 local files shown in tabs below).
tsxconfirm-dialog.tsx129 lines
"use client"; import * as React from "react";import { createPortal } from "react-dom";import { cn } from "./lib/utils";import { getFocusable, lockBodyScroll, registerEscapeLayer, trapFocus } from "./lib/focus-trap"; export type ConfirmDialogProps = { open: boolean; onOpenChange: (open: boolean) => void; title: string; description?: string; confirmLabel?: string; destructive?: boolean; onConfirm: () => void; onCancel: () => void; className?: string;};Props
Interactive Prop Playground
Tweak parsed AST props below to generate ready-to-paste JSX.
tsx3 lines
import { ConfirmDialog } from "@/components/ui/confirm-dialog"; <ConfirmDialog />| Prop | Type | Description |
|---|---|---|
| open | boolean | Controls the open state of the dialog. |
| onOpenChange | (open: boolean) => void | Callback when open state changes. |
| title | string | Dialog title. |
| description | string | Optional description text. |
| confirmLabel | string | Label for the confirm button, defaults to "OK". |
| destructive | boolean | Shows destructive styling (red) on confirm button when true. |
| onConfirm | () => void | Callback when confirm is clicked. |
| onCancel | () => void | Callback when cancel is clicked. |
| className | string | Optional Tailwind or custom CSS classes merged with component styles. |