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
AI Integration Quick Reference
Where It Fits
CometChatConversationStarter is a base component that displays AI-generated conversation suggestions as pill-shaped buttons. It is typically used inside a message composer area or an empty chat view to help users start a conversation. The consumer provides a getConversationStarters function (usually from an AI plugin or custom service), and the component handles loading, error, and empty states automatically.
Minimal Render
.cometchat-conversation-starter
Actions and Events
Callback Props
onSuggestionClick
Called when a user clicks a suggestion button. Receives the suggestion string as the argument.onRetry (Error sub-component)
Called when the user clicks the retry button in the error state. If not provided, the component uses the built-inretry() method from context which re-calls getConversationStarters.
Custom View Slots
| Slot | Signature | Replaces |
|---|---|---|
Loading | { count?, className?, children? } | Shimmer loading state |
Error | { message?, onRetry?, className?, children? } | Error state view |
Empty | { message?, className?, children? } | Empty state view |
Loading
Renders shimmer placeholder pills while suggestions are being fetched. Defaults to 3 shimmer items.- Default
- Custom count
- Custom content
Error
Renders whengetConversationStarters rejects. Shows a localized error message and an optional retry button.
- Default
- Custom message with retry
- Fully custom
Empty
Renders whengetConversationStarters resolves with an empty array. By default renders nothing unless a message or children is provided.
Common Patterns
Retry on error
Using context in custom children
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
.cometchatroot wrapper. - Component CSS (
.cometchat-conversation-starter) consumes these tokens viavar(). - Overrides target
.cometchat-conversation-starterdescendant selectors.
Key Selectors
| Target | Selector |
|---|---|
| Root container | .cometchat-conversation-starter |
| Suggestion pill | .cometchat-conversation-starter__item |
| Suggestion button | .cometchat-conversation-starter__item-button |
| Shimmer container | .cometchat-conversation-starter__shimmer-container |
| Shimmer pill | .cometchat-conversation-starter__shimmer-item |
| Error view | .cometchat-conversation-starter__error-view |
| Retry button | .cometchat-conversation-starter__error-retry |
| Empty view | .cometchat-conversation-starter__empty-view |
| Disabled modifier | .cometchat-conversation-starter__item--disabled |
Example: Brand-themed conversation starters
App.css
Customization Matrix
| What to change | Where | Property/API | Example |
|---|---|---|---|
| Data source | Component props | getConversationStarters on Root | <Root getConversationStarters={fn}> |
| Click handler | Component props | onSuggestionClick on Root | <Root onSuggestionClick={fn}> |
| Loading count | Component props | count on Loading | <Loading count={5} /> |
| Error message | Component props | message on Error | <Error message="Custom error" /> |
| Retry behavior | Component props | onRetry on Error | <Error onRetry={fn} /> |
| Replace loading UI | Component props | children on Loading | <Loading><Spinner /></Loading> |
| Replace error UI | Component props | children on Error | <Error><Custom /></Error> |
| Change visual styling | Global CSS | .cometchat-conversation-starter selectors | See example above |
Props
All props are optional unless noted otherwise.CometChatConversationStarter.Root
getConversationStarters
Async function that returns an array of suggestion strings. Called on mount and on retry.| Type | () => Promise<string[]> |
| Default | undefined |
onSuggestionClick
Called when a suggestion button is clicked. Receives the suggestion string.| Type | (suggestion: string) => void |
| Default | undefined |
className
Custom CSS class appended to the root container.| Type | string |
| Default | undefined |
children
Sub-components for custom composition (Loading, Error, Empty).
| Type | ReactNode |
| Default | undefined |
CometChatConversationStarter.Item
suggestion
The suggestion text to display inside the button.| Type | string |
| Default | undefined |
onClick
Called when this specific item is clicked. Receives the suggestion string.| Type | (suggestion: string) => void |
| Default | undefined |
disabled
Whether the item is disabled. Disabled items cannot be clicked and show reduced opacity.| Type | boolean |
| Default | false |
className
Custom CSS class appended to the item container.| Type | string |
| Default | undefined |
CometChatConversationStarter.Loading
count
Number of shimmer placeholder items to display.| Type | number |
| Default | 3 |
className
Custom CSS class appended to the shimmer container.| Type | string |
| Default | undefined |
children
Custom loading content. When provided, replaces the default shimmer animation.| Type | ReactNode |
| Default | undefined |
CometChatConversationStarter.Error
message
Custom error message text. Overrides the default localized error text.| Type | string |
| Default | "Failed to load conversation starters." |
onRetry
Callback for the retry button. If not provided, uses the built-inretry() from context.
| Type | () => void |
| Default | undefined |
className
Custom CSS class appended to the error container.| Type | string |
| Default | undefined |
children
Custom error content. When provided, replaces the default error message and retry button.| Type | ReactNode |
| Default | undefined |
CometChatConversationStarter.Empty
message
Text to display when no suggestions are available. If not provided and no children, renders nothing.| Type | string |
| Default | undefined |
className
Custom CSS class appended to the empty container.| Type | string |
| Default | undefined |
children
Custom empty content. When provided, replaces the default empty message.| Type | ReactNode |
| Default | undefined |
CSS Selectors
| Target | Selector |
|---|---|
| Root | .cometchat-conversation-starter |
| Suggestion pill | .cometchat-conversation-starter__item |
| Suggestion button | .cometchat-conversation-starter__item-button |
| Disabled item | .cometchat-conversation-starter__item--disabled |
| Shimmer container | .cometchat-conversation-starter__shimmer-container |
| Shimmer pill | .cometchat-conversation-starter__shimmer-item |
| Error view | .cometchat-conversation-starter__error-view |
| Retry button | .cometchat-conversation-starter__error-retry |
| Empty view | .cometchat-conversation-starter__empty-view |