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
CometChatSmartReplies is a base component that displays AI-powered reply suggestions as clickable buttons. It is typically rendered above the message composer input, triggered by an AI action button or automatically when the AI plugin detects a suitable context. The consumer provides a getSmartReplies function (usually from an AI plugin or custom service), and the component handles loading, error, and empty states automatically. When the user clicks a suggestion, the onSuggestionClick callback fires so the parent can send or insert the reply.
Minimal Render
.cometchat-smart-replies
Actions and Events
Callback Props
onSuggestionClick
Called when the user clicks a reply suggestion button. Receives the reply string.onClose
Called when the user clicks the close button or presses the Escape key while the component is focused.onRetry (Error sub-component)
Called when the user clicks the retry button in the error state. Falls back to the internalretry() method if not provided.
Custom View Slots
| Slot | Sub-component | Replaces |
|---|---|---|
| Header | <CometChatSmartReplies.Header> | Default header with title and close button |
| Loading | <CometChatSmartReplies.Loading> | Default shimmer bars |
| Error | <CometChatSmartReplies.Error> | Default error message with retry |
| Empty | <CometChatSmartReplies.Empty> | Default empty message |
Custom Header
Passchildren to Header to replace the default title and close button.
Custom Error with Retry
Passchildren to Error to fully replace the error view.
Custom Loading
Passchildren to Loading to replace the default shimmer bars.
Common Patterns
Simple Usage (No Children — Default Layout)
When no children are provided, the Root renders the default layout automatically.Custom Header Title
Without Close Button
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-smart-replies) consumes these tokens viavar(). - Overrides target
.cometchat-smart-repliesdescendant selectors.
Key Selectors
| Target | Selector |
|---|---|
| Root card | .cometchat-smart-replies |
| Header row | .cometchat-smart-replies__header |
| Header title | .cometchat-smart-replies__header-title |
| Close button | .cometchat-smart-replies__header-close-button |
| Items container | .cometchat-smart-replies__items-container |
| Reply item | .cometchat-smart-replies__item |
| Shimmer container | .cometchat-smart-replies__shimmer-container |
| Shimmer bar | .cometchat-smart-replies__shimmer-item |
| Error view | .cometchat-smart-replies__error-view |
| Retry button | .cometchat-smart-replies__error-retry |
| Empty view | .cometchat-smart-replies__empty-view |
Example: Brand-themed smart replies
App.css
Customization Matrix
| What to change | Where | Property/API | Example |
|---|---|---|---|
| Handle reply selection | Root props | onSuggestionClick callback | onSuggestionClick={(r) => send(r)} |
| Close behavior | Root props | onClose callback | onClose={() => hide()} |
| Header text | Header props | title | title="AI Suggestions" |
| Hide close button | Header props | showCloseButton | showCloseButton={false} |
| Error message | Error props | message | message="Failed" |
| Retry behavior | Error props | onRetry | onRetry={() => refetch()} |
| Empty message | Empty props | message | message="Nothing here" |
| Shimmer count | Loading props | count | count={5} |
| Replace any section | Sub-component | children | Pass custom JSX |
| Change visual styling | Global CSS | .cometchat-smart-replies selectors | See CSS Selectors |
Props
All props are optional unless noted otherwise.getSmartReplies (Root)
Async function that returns an array of reply suggestion strings. Required.| Type | () => Promise<string[]> |
| Default | — |
onSuggestionClick (Root)
Callback when a reply suggestion is clicked. Receives the reply string.| Type | (reply: string) => void |
| Default | undefined |
onClose (Root)
Callback when the close button is clicked or Escape is pressed.| Type | () => void |
| Default | undefined |
className (Root, Header, Item, Loading, Error, Empty)
Optional custom CSS class name appended to the component’s root element.| Type | string |
| Default | undefined |
children (Root, Header, Loading, Error, Empty)
Custom content that replaces the default rendering of the sub-component.| Type | ReactNode |
| Default | undefined |
reply (Item)
The reply text to display. Required.| Type | string |
| Default | — |
title (Header)
Custom title text displayed in the header.| Type | string |
| Default | "Suggest a reply" |
showCloseButton (Header)
Whether to show the close button in the header.| Type | boolean |
| Default | true |
count (Loading)
Number of shimmer bars to display during loading.| Type | number |
| Default | 3 |
message (Error)
Custom error message text.| Type | string |
| Default | "Looks like something went wrong" |
onRetry (Error)
Callback to retry fetching replies. Falls back to the internal retry mechanism if not provided.| Type | () => void |
| Default | undefined |
message (Empty)
Custom empty state message text.| Type | string |
| Default | "No Suggestions Available" |
CSS Selectors
| Target | Selector |
|---|---|
| Root card | .cometchat-smart-replies |
| Header row | .cometchat-smart-replies__header |
| Header title | .cometchat-smart-replies__header-title |
| Close button | .cometchat-smart-replies__header-close-button |
| Items container | .cometchat-smart-replies__items-container |
| Reply item button | .cometchat-smart-replies__item |
| Reply item hover | .cometchat-smart-replies__item:hover |
| Reply item focus | .cometchat-smart-replies__item:focus-visible |
| Shimmer container | .cometchat-smart-replies__shimmer-container |
| Shimmer bar | .cometchat-smart-replies__shimmer-item |
| Error view | .cometchat-smart-replies__error-view |
| Retry button | .cometchat-smart-replies__error-retry |
| Empty view | .cometchat-smart-replies__empty-view |