LogoStarterkitpro
Components

Confirmation Modal

A dialog for confirming user actions before proceeding

A modal dialog component that asks users to confirm important actions before proceeding, helping prevent accidental operations.

Confirmation Modal

Usage

Example
import { useConfirmationDialog } from "@/providers/confirmation-dialog-provider";
 
export default function DeleteAccount() {
  const { showConfirmation } = useConfirmationDialog();
 
  const handleDelete = async () => {
    // Handle account deletion after confirmation
 
    // ...other code
    const confirmed = await showConfirmation({
      title: "Delete Account",
      description:
        "Are you sure you want to delete your account? All of your data will be permanently removed. This action cannot be undone.",
      confirmText: "Delete",
      cancelText: "Cancel",
      variant: "destructive",
      icon: <AlertTriangle className="size-5 text-destructive" />,
    });
    if (!confirmed) return;
    // ...other code
  };
 
  return (
    <>
      <button onClick={() => setShowConfirmation(true)}>Delete Account</button>
    </>
  );
}

Tips

Confirmation Modal Variants

The Confirmation Modal isn't limited to destructive actions. It's versatile and can be used for any action requiring user confirmation. Available variants include:

  • default
  • destructive
  • outline
  • secondary
  • ghost
  • link Each variant offers a distinct visual style to match the context and importance of the action being confirmed.
  • Use for destructive or irreversible actions like deleting content
  • Make the consequences of the action clear in the description
  • Use color to indicate the severity of the action (red for destructive)

On this page