Skip to main content

Documentation Index

Fetch the complete documentation index at: https://cometchat-22654f5b-react-uikit-v7.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

{
  "component": "CometChatConfirmDialog",
  "package": "@cometchat/chat-uikit-react",
  "import": "import { CometChatConfirmDialog } from \"@cometchat/chat-uikit-react\";",
  "cssImport": "import \"@cometchat/chat-uikit-react/css-variables.css\";",
  "description": "A modal confirmation dialog with icon, title, message, and action buttons for destructive or important actions requiring explicit user confirmation.",
  "cssRootClass": ".cometchat-confirm-dialog",
  "primaryOutput": {
    "prop": "onConfirm",
    "type": "() => void | Promise<void>"
  },
  "props": {
    "data": {
      "title": { "type": "string", "default": "localized 'conversation_delete_title'" },
      "message": { "type": "string", "default": "localized 'conversation_delete_subtitle'" },
      "cancelText": { "type": "string", "default": "localized 'conversation_delete_confirm_no'" },
      "confirmText": { "type": "string", "default": "localized 'conversation_delete_confirm_yes'" },
      "errorText": { "type": "string", "default": "undefined" }
    },
    "callbacks": {
      "onClose": { "type": "() => void", "default": "undefined" },
      "onConfirm": { "type": "() => void | Promise<void>", "default": "undefined" },
      "onCancel": { "type": "() => void", "default": "calls onClose" }
    },
    "behavior": {
      "isOpen": { "type": "boolean", "default": "undefined (uncontrolled)" },
      "closeOnOutsideClick": { "type": "boolean", "default": "true" },
      "variant": { "type": "'danger' | 'warning' | 'info'", "default": "'danger'" },
      "isLoading": { "type": "boolean", "default": "auto-managed from Promise" }
    },
    "viewSlots": {
      "icon": { "type": "ReactNode", "default": "variant-based delete icon" },
      "children (Content)": { "type": "ReactNode", "default": "title + message" },
      "children (Actions)": { "type": "ReactNode", "default": "cancel + confirm buttons" }
    }
  },
  "events": [],
  "sdkListeners": [],
  "types": {
    "CometChatConfirmDialogVariant": "'danger' | 'warning' | 'info'"
  }
}

Where It Fits

CometChatConfirmDialog is a base modal component used whenever a destructive or important action needs explicit user confirmation. Wire it into feature components like CometChatConversations (delete conversation), CometChatGroupMembers (kick/ban member), or CometChatMessageList (image moderation) to gate critical actions behind a confirmation step.
import { useState } from "react";
import { CometChatConfirmDialog } from "@cometchat/chat-uikit-react";
import "@cometchat/chat-uikit-react/css-variables.css";

function App() {
  const [showConfirm, setShowConfirm] = useState(false);

  const handleDelete = async () => {
    await deleteConversation(conversationId);
  };

  return (
    <div>
      <button onClick={() => setShowConfirm(true)}>Delete Conversation</button>
      <CometChatConfirmDialog.Root
        isOpen={showConfirm}
        onClose={() => setShowConfirm(false)}
        variant="danger"
      >
        <CometChatConfirmDialog.Icon />
        <CometChatConfirmDialog.Content
          title="Delete Conversation?"
          message="This action cannot be undone."
        />
        <CometChatConfirmDialog.Actions
          cancelText="Cancel"
          confirmText="Delete"
          onConfirm={handleDelete}
        />
      </CometChatConfirmDialog.Root>
    </div>
  );
}

Minimal Render

import { CometChatConfirmDialog } from "@cometchat/chat-uikit-react";
import "@cometchat/chat-uikit-react/css-variables.css";

function Demo() {
  return (
    <CometChatConfirmDialog.Root isOpen={true} onClose={() => {}}>
      <CometChatConfirmDialog.Icon />
      <CometChatConfirmDialog.Content />
      <CometChatConfirmDialog.Actions />
    </CometChatConfirmDialog.Root>
  );
}
Root CSS class: .cometchat-confirm-dialog

Actions and Events

Callback Props

onConfirm

Called when the confirm button is clicked. If it returns a Promise, the button automatically shows a loading state and catches errors.
<CometChatConfirmDialog.Actions
  onConfirm={async () => {
    await api.deleteConversation(id);
  }}
/>

onCancel

Called when the cancel button is clicked. Falls back to onClose from context if not provided.
<CometChatConfirmDialog.Actions
  onCancel={() => {
    console.log("User cancelled");
    setOpen(false);
  }}
/>

onClose

Called when the dialog requests to close (Escape key, outside click, or cancel button).
<CometChatConfirmDialog.Root
  isOpen={open}
  onClose={() => setOpen(false)}
>
  {/* ... */}
</CometChatConfirmDialog.Root>

Custom View Slots

SlotSignatureReplaces
icon (Icon)ReactNodeDefault variant-based icon
children (Content)ReactNodeTitle + message text
children (Actions)ReactNodeCancel + confirm buttons

Custom Icon

Replace the default delete icon with any React element.
<CometChatConfirmDialog.Icon
  icon={
    <svg width="36" height="36" viewBox="0 0 24 24" fill="none">
      <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z" fill="#f5a623" />
    </svg>
  }
/>

Custom Content

Override the title/message with fully custom children.
<CometChatConfirmDialog.Content>
  <div style={{ textAlign: "center" }}>
    <h3>Are you absolutely sure?</h3>
    <p>This will permanently remove all messages.</p>
    <p><strong>This cannot be undone.</strong></p>
  </div>
</CometChatConfirmDialog.Content>

Custom Actions

Replace the default buttons with fully custom action elements.
<CometChatConfirmDialog.Actions>
  <button onClick={handleCancel}>Go Back</button>
  <button onClick={handleConfirm} style={{ background: "red", color: "white" }}>
    Yes, Delete Everything
  </button>
</CometChatConfirmDialog.Actions>

CSS Architecture

The component uses CSS custom properties (design tokens) defined in @cometchat/chat-uikit-react/css-variables.css. The cascade:
  1. Global tokens set on the .cometchat root wrapper.
  2. Component CSS (.cometchat-confirm-dialog) consumes these tokens via var().
  3. Overrides target .cometchat-confirm-dialog descendant selectors.

Key Selectors

TargetSelector
Backdrop.cometchat-confirm-dialog__backdrop
Dialog container.cometchat-confirm-dialog
Icon wrapper.cometchat-confirm-dialog__icon
Content area.cometchat-confirm-dialog__content
Title.cometchat-confirm-dialog__content-title
Message.cometchat-confirm-dialog__content-message
Actions row.cometchat-confirm-dialog__actions
Cancel button.cometchat-confirm-dialog__actions-cancel
Confirm button.cometchat-confirm-dialog__actions-confirm
Error banner.cometchat-confirm-dialog__error

Example: Brand-themed dialog

.cometchat-confirm-dialog {
  border-radius: 24px;
  border-color: #e0e0e0;
}

.cometchat-confirm-dialog__icon {
  background: #fce4ec;
}

.cometchat-confirm-dialog__actions-confirm--danger button {
  background: #d32f2f;
}

Customization Matrix

What to changeWhereProperty/APIExample
Override behaviorComponent propsonConfirm, onCancel, onCloseonConfirm={handleDelete}
Control open stateComponent propsisOpen, onCloseisOpen={showDialog}
Change variantComponent propsvariantvariant="warning"
Disable outside clickComponent propscloseOnOutsideClickcloseOnOutsideClick={false}
Replace iconSub-component propicon on Icon<Icon icon={<MyIcon />} />
Replace contentSub-component childrenchildren on Content<Content><Custom /></Content>
Replace buttonsSub-component childrenchildren on Actions<Actions><Custom /></Actions>
Change visual stylingGlobal CSS.cometchat-confirm-dialog selectorsSee CSS Selectors table

Props

All props are optional unless noted otherwise.

cancelText

Text for the cancel button.
Typestring
DefaultLocalized "Cancel"

children (Root)

Sub-components to render inside the dialog. Required on Root.
TypeReactNode
DefaultIcon + Content + Actions

className

Optional custom CSS class name applied to the component root.
Typestring
Defaultundefined

closeOnOutsideClick

Whether clicking outside the dialog closes it.
Typeboolean
Defaulttrue

confirmText

Text for the confirm button.
Typestring
DefaultLocalized "Confirm"

errorText

Error message displayed above the action buttons. Auto-set when onConfirm rejects.
Typestring
Defaultundefined

icon

Custom icon element for the Icon sub-component.
TypeReactNode
DefaultVariant-based delete icon

isLoading

Whether the confirm button shows a loading state. Auto-managed when onConfirm returns a Promise.
Typeboolean
DefaultAuto-managed

isOpen

Whether the dialog is open. When provided, the component is controlled.
Typeboolean
Defaultundefined (uncontrolled)

message

Descriptive message text in the Content sub-component.
Typestring
DefaultLocalized delete subtitle

onCancel

Callback when the cancel button is clicked. Falls back to onClose.
Type() => void
DefaultCalls onClose

onClose

Callback when the dialog requests to close.
Type() => void
Defaultundefined

onConfirm

Callback when the confirm button is clicked. Can return a Promise for async operations.
Type() => void | Promise<void>
Defaultundefined

title

Title text in the Content sub-component.
Typestring
DefaultLocalized delete title

variant

Visual variant affecting icon and confirm button color.
Type'danger' | 'warning' | 'info'
Default'danger'
type CometChatConfirmDialogVariant = 'danger' | 'warning' | 'info';

CSS Selectors

TargetSelector
Backdrop overlay.cometchat-confirm-dialog__backdrop
Dialog container.cometchat-confirm-dialog
Icon wrapper.cometchat-confirm-dialog__icon
Icon danger modifier.cometchat-confirm-dialog__icon--danger
Icon warning modifier.cometchat-confirm-dialog__icon--warning
Icon info modifier.cometchat-confirm-dialog__icon--info
Default icon element.cometchat-confirm-dialog__icon-default
Content area.cometchat-confirm-dialog__content
Title text.cometchat-confirm-dialog__content-title
Message text.cometchat-confirm-dialog__content-message
Actions row.cometchat-confirm-dialog__actions
Cancel button wrapper.cometchat-confirm-dialog__actions-cancel
Confirm button wrapper.cometchat-confirm-dialog__actions-confirm
Confirm danger modifier.cometchat-confirm-dialog__actions-confirm--danger
Confirm warning modifier.cometchat-confirm-dialog__actions-confirm--warning
Confirm info modifier.cometchat-confirm-dialog__actions-confirm--info
Confirm loading modifier.cometchat-confirm-dialog__actions-confirm--loading
Error banner.cometchat-confirm-dialog__error