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

Installation

Tokens guide →

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

npx bigbullui add confirm-dialog

Or install the full npm package:

npm install bigbullui

Usage

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 helpers

Zero 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 />
PropTypeDescription
openbooleanControls the open state of the dialog.
onOpenChange(open: boolean) => voidCallback when open state changes.
titlestringDialog title.
descriptionstringOptional description text.
confirmLabelstringLabel for the confirm button, defaults to "OK".
destructivebooleanShows destructive styling (red) on confirm button when true.
onConfirm() => voidCallback when confirm is clicked.
onCancel() => voidCallback when cancel is clicked.
classNamestringOptional Tailwind or custom CSS classes merged with component styles.