Command Palette

Search for a command to run...

GitHub
ComponentsConfirm Dialog

Confirm Dialog

A singleton, promise-based confirmation system inspired by Sonner. Handles multiple stacked dialogs with ease.

Singleton
Promise-Based

Interactive Demo

Test the functional API. Notice how dialogs stack and scale when triggered simultaneously.

Installation

pnpm dlx shadcn@latest add https://micto-ui-kit.misangono.net/r/micto/confirm-dialog.json

Setup

Add the ConfirmProvider to your root layout or app component. This ensures the confirmation stack is available globally.

import { ConfirmProvider } from "@/components/micto/confirm-dialog"

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body>
        {children}
        <ConfirmProvider />
      </body>
    </html>
  )
}

Functional API Usage

Import confirmDialog and await the result. No component wrapping or local state required per call.

import { confirmDialog } from "@/components/micto/confirm-dialog"

export function DeleteButton() {
  const handleDelete = async () => {
    const ok = await confirmDialog({
      title: "Are you absolutely sure?",
      body: "This action cannot be undone. This will permanently delete your account.",
      icon: "danger",
      confirmText: "Delete Account",
    });

    if (ok) {
      // Proceed with deletion
    }
  }

  return <Button onClick={handleDelete}>Delete</Button>
}

API Reference

Options passed to the lifecycle functions.

confirmDialog(options)

PropTypeDefaultDescription
titlestringundefinedThe title of the dialog shown in bold.
bodystring | ReactNoderequiredThe main content of the alert. Supports custom components.
icon'warning' | 'danger' | 'info' | 'ghost''warning'The visual style and Lucide icon to display.
confirmTextstring'Confirm'Text for the primary action button.
cancelTextstring'Cancel'Text for the secondary/dismiss action button.
onConfirm() => Promise<boolean | void> | boolean | voidundefinedOptional async handler called when confirming. Returning false prevents closing.
onCancel() => voidundefinedOptional callback called when the dialog is dismissed or cancelled.
size'sm' | 'md' | 'lg''md'The width and text size profile of the dialog.
classNamestringundefinedTailwind classes to override the dialog styling (e.g. width, text-alignment).
dismissablebooleantrueWhether clicking the backdrop closes the dialog.

ConfirmProvider

PropTypeDefaultDescription
defaultSize'sm' | 'md' | 'lg''md'Setting a project-wide default size for all confirmations.
classNamestringundefinedStyling the backdrop and stack container globally.