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" : "CometChatCreatePoll" ,
"package" : "@cometchat/chat-uikit-react" ,
"import" : "import { CometChatCreatePoll } from \" @cometchat/chat-uikit-react \" ;" ,
"description" : "Modal form for creating poll messages with question, dynamic options, and validation." ,
"cssRootClass" : ".cometchat-create-poll" ,
"props" : {
"data" : {
"user" : { "type" : "CometChat.User" , "default" : "undefined" },
"group" : { "type" : "CometChat.Group" , "default" : "undefined" },
"replyToMessage" : { "type" : "CometChat.BaseMessage" , "default" : "undefined" }
},
"behavior" : {
"defaultAnswers" : { "type" : "number" , "default" : "2" }
},
"callbacks" : {
"onClose" : { "type" : "() => void" , "default" : "undefined" },
"onPollCreated" : { "type" : "() => void" , "default" : "undefined" },
"onError" : { "type" : "(error: unknown) => void" , "default" : "undefined" }
},
"text" : {
"title" : { "type" : "string" , "default" : "localized 'Create Poll'" },
"questionPlaceholderText" : { "type" : "string" , "default" : "localized placeholder" },
"answerPlaceholderText" : { "type" : "string" , "default" : "localized placeholder" },
"answerHelpText" : { "type" : "string" , "default" : "localized help text" },
"addAnswerText" : { "type" : "string" , "default" : "localized 'Add Option'" },
"createPollButtonText" : { "type" : "string" , "default" : "localized 'Create'" }
}
}
}
Where It Fits
CometChatCreatePoll is a modal dialog opened from the message composer’s attachment menu when the Polls plugin is registered. It creates a poll via CometChat.callExtension('polls', 'POST', 'v2/create', payload).
import { useState } from "react" ;
import { CometChatCreatePoll } from "@cometchat/chat-uikit-react" ;
import "@cometchat/chat-uikit-react/css-variables.css" ;
function ChatComposer ({ user }) {
const [ showPoll , setShowPoll ] = useState ( false );
return (
<>
< button onClick = { () => setShowPoll ( true ) } > Create Poll </ button >
{ showPoll && (
< div style = { { position: "fixed" , inset: 0 , background: "rgba(0,0,0,0.5)" , display: "flex" , alignItems: "center" , justifyContent: "center" } } >
< CometChatCreatePoll
user = { user }
onClose = { () => setShowPoll ( false ) }
onPollCreated = { () => setShowPoll ( false ) }
/>
</ div >
) }
</>
);
}
Minimal Render
import { CometChatCreatePoll } from "@cometchat/chat-uikit-react" ;
import "@cometchat/chat-uikit-react/css-variables.css" ;
function Demo () {
return < CometChatCreatePoll onClose = { () => {} } /> ;
}
Root CSS class: .cometchat-create-poll
Features
Question input with placeholder text
Dynamic answer options (add/remove, minimum 2, maximum 12)
Validation: requires non-empty question and at least 2 non-empty options
Loading state on the create button during API call
Error display with role="alert"
Reply-to-message support via quotedMessageId
Escape key closes the dialog
Focus restoration on unmount
role="dialog", aria-modal="true", aria-labelledby
Props
All props are optional unless noted otherwise.
user
User to send the poll to (for 1:1 conversations).
Type CometChat.UserDefault undefined
group
Group to send the poll to (for group conversations).
Type CometChat.GroupDefault undefined
replyToMessage
Message to reply to (for quoted replies). When provided, the poll is sent as a reply to this message.
Type CometChat.BaseMessageDefault undefined
defaultAnswers
Default number of answer option inputs. Minimum 2, maximum 12.
onClose
Callback when close is requested (close button or Escape key).
Type () => voidDefault undefined
onPollCreated
Callback when the poll is created successfully.
Type () => voidDefault undefined
onError
Callback when an error occurs during poll creation.
Type (error: unknown) => voidDefault undefined
title
Override for the dialog title text.
Type stringDefault Localized "Create Poll"
questionPlaceholderText
Placeholder text for the question input field.
Type stringDefault Localized placeholder
answerPlaceholderText
Placeholder text for answer option input fields.
Type stringDefault Localized placeholder
answerHelpText
Help text displayed below the answer options section.
Type stringDefault Localized help text
addAnswerText
Text for the “Add Option” button.
Type stringDefault Localized "Add Option"
createPollButtonText
Text for the “Create” submit button.
Type stringDefault Localized "Create"
CSS Selectors
Target Selector Root .cometchat-create-pollHeader .cometchat-create-poll__headerTitle .cometchat-create-poll__header-titleClose button .cometchat-create-poll__header-closeQuestion input .cometchat-create-poll__question-inputOption input .cometchat-create-poll__option-inputRemove button .cometchat-create-poll__option-removeAdd button .cometchat-create-poll__add-buttonCreate button .cometchat-create-poll__create-buttonError message .cometchat-create-poll__error