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.
AI Integration Quick Reference
{
"component" : "CometChatFlagMessageDialog" ,
"package" : "@cometchat/chat-uikit-react" ,
"import" : "import { CometChatFlagMessageDialog } from \" @cometchat/chat-uikit-react \" ;" ,
"cssImport" : "import \" @cometchat/chat-uikit-react/css-variables.css \" ;" ,
"description" : "A modal dialog for reporting/flagging messages by selecting a reason and optionally providing a remark." ,
"cssRootClass" : ".cometchat-flag-message-dialog" ,
"primaryOutput" : {
"prop" : "onSubmit" ,
"type" : "(messageId: string, reasonId: string, remark?: string) => Promise<boolean>"
},
"props" : {
"data" : {
"message" : { "type" : "CometChat.BaseMessage" , "note" : "Required" },
"title" : { "type" : "string" , "default" : "localized 'flag_message_title'" },
"subtitle" : { "type" : "string" , "default" : "localized 'flag_message_subtitle'" },
"cancelText" : { "type" : "string" , "default" : "localized 'flag_message_confirm_no'" },
"submitText" : { "type" : "string" , "default" : "localized 'flag_message_confirm_yes'" },
"label" : { "type" : "string" , "default" : "localized 'flag_message_remark_label'" },
"placeholder" : { "type" : "string" , "default" : "localized 'flag_message_remark_placeholder'" },
"maxLength" : { "type" : "number" , "default" : "500" }
},
"callbacks" : {
"onClose" : { "type" : "() => void" , "default" : "undefined" },
"onSubmit" : { "type" : "(messageId, reasonId, remark?) => Promise<boolean>" , "default" : "undefined" },
"onError" : { "type" : "(error: CometChatException) => void" , "default" : "undefined" }
},
"behavior" : {
"isOpen" : { "type" : "boolean" , "default" : "undefined (uncontrolled)" },
"closeOnOutsideClick" : { "type" : "boolean" , "default" : "true" }
}
},
"events" : [],
"sdkListeners" : [],
"types" : {}
}
Where It Fits
CometChatFlagMessageDialog is a base modal component used when a user wants to report an inappropriate message. It fetches flag reasons from the CometChat SDK, presents them as selectable options, and optionally collects a remark. Wire it into CometChatMessageList as a message option to enable message reporting.
import { useState } from "react" ;
import { CometChatFlagMessageDialog } from "@cometchat/chat-uikit-react" ;
import "@cometchat/chat-uikit-react/css-variables.css" ;
function MessageActions ({ message }) {
const [ showFlag , setShowFlag ] = useState ( false );
const handleSubmit = async ( messageId , reasonId , remark ) => {
await reportMessage ( messageId , reasonId , remark );
return true ;
};
return (
< div >
< button onClick = { () => setShowFlag ( true ) } > Report </ button >
< CometChatFlagMessageDialog.Root
message = { message }
isOpen = { showFlag }
onClose = { () => setShowFlag ( false ) }
onSubmit = { handleSubmit }
>
< CometChatFlagMessageDialog.Header />
< CometChatFlagMessageDialog.Reasons />
< CometChatFlagMessageDialog.Remark />
< CometChatFlagMessageDialog.Actions />
</ CometChatFlagMessageDialog.Root >
</ div >
);
}
Minimal Render
import { CometChatFlagMessageDialog } from "@cometchat/chat-uikit-react" ;
import "@cometchat/chat-uikit-react/css-variables.css" ;
function Demo ({ message }) {
return (
< CometChatFlagMessageDialog.Root message = { message } isOpen = { true } onClose = { () => {} } >
< CometChatFlagMessageDialog.Header />
< CometChatFlagMessageDialog.Reasons />
< CometChatFlagMessageDialog.Remark />
< CometChatFlagMessageDialog.Actions />
</ CometChatFlagMessageDialog.Root >
);
}
Root CSS class: .cometchat-flag-message-dialog
Common Patterns
Omit the Remark sub-component to hide the remark textarea. This replaces the v6 hideFlagRemarkField boolean prop.
< CometChatFlagMessageDialog.Root message = { message } isOpen = { open } onClose = { () => setOpen ( false ) } >
< CometChatFlagMessageDialog.Header />
< CometChatFlagMessageDialog.Reasons />
< CometChatFlagMessageDialog.Actions />
</ CometChatFlagMessageDialog.Root >
Controlled Mode
Manage the open/close state externally for full control.
function FlagDialog ({ message }) {
const [ open , setOpen ] = useState ( false );
return (
<>
< button onClick = { () => setOpen ( true ) } > Report Message </ button >
< CometChatFlagMessageDialog.Root
message = { message }
isOpen = { open }
onClose = { () => setOpen ( false ) }
onSubmit = {async ( msgId , reasonId , remark ) => {
await api . flagMessage ( msgId , reasonId , remark );
return true ;
} }
>
< CometChatFlagMessageDialog.Header />
< CometChatFlagMessageDialog.Reasons />
< CometChatFlagMessageDialog.Remark />
< CometChatFlagMessageDialog.Actions />
</ CometChatFlagMessageDialog.Root >
</>
);
}
Replace the default header with fully custom content using children.
< CometChatFlagMessageDialog.Header >
< div style = { { textAlign: "center" } } >
< h3 > Report This Message </ h3 >
< p > Help us keep the community safe. </ p >
</ div >
</ CometChatFlagMessageDialog.Header >
Actions and Events
Callback Props
onSubmit
Called when the user clicks the submit/report button. Receives the message ID, selected reason ID, and optional remark. Return true to close the dialog, or throw to show an error.
< CometChatFlagMessageDialog.Root
message = { message }
isOpen = { open }
onClose = { () => setOpen ( false ) }
onSubmit = {async ( messageId , reasonId , remark ) => {
const result = await flagMessageAPI ( messageId , reasonId , remark );
return result . success ;
} }
>
{ /* ... */ }
</ CometChatFlagMessageDialog.Root >
onClose
Called when the dialog requests to close (Escape key, outside click, or cancel button).
< CometChatFlagMessageDialog.Root
message = { message }
isOpen = { open }
onClose = { () => setOpen ( false ) }
>
{ /* ... */ }
</ CometChatFlagMessageDialog.Root >
onError
Called when an SDK error occurs (e.g., fetching flag reasons fails).
< CometChatFlagMessageDialog.Root
message = { message }
isOpen = { open }
onClose = { () => setOpen ( false ) }
onError = { ( error ) => console . error ( "Flag error:" , error ) }
>
{ /* ... */ }
</ CometChatFlagMessageDialog.Root >
Custom View Slots
Slot Signature Replaces children (Header)ReactNodeTitle + subtitle text children (Reasons)ReactNodeDefault reason radio buttons children (Actions)ReactNodeCancel + submit buttons
< CometChatFlagMessageDialog.Header >
< div >
< h3 > Custom Report Title </ h3 >
< p > Custom description text. </ p >
</ div >
</ CometChatFlagMessageDialog.Header >
.cometchat-flag-message-dialog__header {
padding : 16 px ;
border-bottom : 1 px solid #eee ;
}
Custom Actions
< CometChatFlagMessageDialog.Actions >
< button onClick = { handleCancel } > Go Back </ button >
< button onClick = { handleSubmit } style = { { background: "red" , color: "white" } } >
Submit Report
</ button >
</ CometChatFlagMessageDialog.Actions >
.cometchat-flag-message-dialog__actions {
justify-content : flex-end ;
}
CSS Architecture
The component uses CSS custom properties (design tokens) defined in @cometchat/chat-uikit-react/css-variables.css. The cascade:
Global tokens set on the .cometchat root wrapper.
Component CSS (.cometchat-flag-message-dialog) consumes these tokens via var().
Overrides target .cometchat-flag-message-dialog descendant selectors.
Key Selectors
Target Selector Backdrop .cometchat-flag-message-dialog__backdropDialog container .cometchat-flag-message-dialogHeader .cometchat-flag-message-dialog__headerTitle .cometchat-flag-message-dialog__header-titleSubtitle .cometchat-flag-message-dialog__header-subtitleReasons container .cometchat-flag-message-dialog__reasonsReason button .cometchat-flag-message-dialog__reasonSelected reason .cometchat-flag-message-dialog__reason--selectedRemark area .cometchat-flag-message-dialog__remarkRemark textarea .cometchat-flag-message-dialog__remark-inputError banner .cometchat-flag-message-dialog__errorActions row .cometchat-flag-message-dialog__actionsCancel button .cometchat-flag-message-dialog__actions-cancelSubmit button .cometchat-flag-message-dialog__actions-submit
Example: Brand-themed dialog
.cometchat-flag-message-dialog {
border-radius : 24 px ;
max-width : 500 px ;
}
.cometchat-flag-message-dialog__reason--selected {
border-color : #6851ff ;
background : #f0edff ;
color : #6851ff ;
}
.cometchat-flag-message-dialog__actions-submit button {
background : #6851ff ;
}
Customization Matrix
What to change Where Property/API Example Override submit behavior Component props onSubmitonSubmit={handleFlag}Control open state Component props isOpen, onCloseisOpen={showDialog}Disable outside click Component props closeOnOutsideClickcloseOnOutsideClick={false}Hide remark field Composition Omit Remark sub-component Don’t render <Remark /> Replace header Sub-component children children on Header<Header><Custom /></Header>Replace buttons Sub-component children children on Actions<Actions><Custom /></Actions>Change visual styling Global CSS .cometchat-flag-message-dialog selectorsSee CSS Selectors table
Props
All props are optional unless noted otherwise.
cancelText
Text for the cancel button.
Type stringDefault Localized "Cancel"
children (Root)
Sub-components to render inside the dialog.
Type ReactNodeDefault Header + Reasons + Remark + Actions
className
Optional custom CSS class name applied to the component root.
Type stringDefault undefined
closeOnOutsideClick
Whether clicking outside the dialog closes it.
isOpen
Whether the dialog is open. When provided, the component is controlled.
Type booleanDefault undefined (uncontrolled)
label
Label text for the remark textarea.
Type stringDefault Localized "Reason"
maxLength
Maximum character count for the remark textarea.
message
The message being flagged. Required on Root.
Type CometChat.BaseMessageDefault —
onClose
Callback when the dialog requests to close.
Type () => voidDefault undefined
onError
Callback when an SDK error occurs.
Type (error: CometChat.CometChatException) => voidDefault undefined
onSubmit
Custom submit handler. Receives message ID, reason ID, and optional remark.
Type (messageId: string, reasonId: string, remark?: string) => Promise<boolean>Default undefined
placeholder
Placeholder text for the remark textarea.
Type stringDefault Localized placeholder
submitText
Text for the submit/report button.
Type stringDefault Localized "Report"
subtitle
Subtitle text in the Header sub-component.
Type stringDefault Localized description
title
Title text in the Header sub-component.
Type stringDefault Localized "Report a Message"
CSS Selectors
Target Selector Backdrop overlay .cometchat-flag-message-dialog__backdropDialog container .cometchat-flag-message-dialogHeader area .cometchat-flag-message-dialog__headerTitle text .cometchat-flag-message-dialog__header-titleSubtitle text .cometchat-flag-message-dialog__header-subtitleReasons container .cometchat-flag-message-dialog__reasonsReason button .cometchat-flag-message-dialog__reasonSelected reason .cometchat-flag-message-dialog__reason--selectedRemark area .cometchat-flag-message-dialog__remarkRemark label .cometchat-flag-message-dialog__remark-labelRemark textarea .cometchat-flag-message-dialog__remark-inputError banner .cometchat-flag-message-dialog__errorActions row .cometchat-flag-message-dialog__actionsCancel button wrapper .cometchat-flag-message-dialog__actions-cancelSubmit button wrapper .cometchat-flag-message-dialog__actions-submit