ChatMessage API
API reference docs for the React ChatMessage component. Learn about the props, CSS, and other APIs of this exported module.
Demos
Import
import { ChatMessage } from '@mui/x-chat/ChatMessage';
// or
import { ChatMessage } from '@mui/x-chat';Learn about the difference by reading this guide on minimizing bundle size.
| Name | Type | Description |
|---|---|---|
| messageId* | string | |
| classes | Partial | See CSS classes API below for more details. |
| isGrouped | bool | |
| slotProps | MessageRootSlotProps | |
| slots | Partial | See Slots API below for more details. |
The component cannot hold a ref.
| Slot name | Class name | Default component | Description |
|---|---|---|---|
| root | .MuiChatMessage-root |
These class names are useful for styling with CSS. They are applied to the component's slots when specific states are triggered.
| Class name | Rule name | Description |
|---|---|---|
| .Mui-error | Applied when the message has an error status | |
| .MuiChatMessage-actions | actions | Styles applied to the message actions element. |
| .MuiChatMessage-authorLabel | authorLabel | Styles applied to the message author label element. |
| .MuiChatMessage-avatar | avatar | Styles applied to the message avatar element. |
| .MuiChatMessage-bubble | bubble | Styles applied to the message bubble element inside content. |
| .MuiChatMessage-content | content | Styles applied to the message content element. |
| .MuiChatMessage-dateDivider | dateDivider | Styles applied to the date divider element. |
| .MuiChatMessage-group | group | Styles applied to the message group element. |
| .MuiChatMessage-groupAuthorName | groupAuthorName | Class applied to the group author name element. |
| .MuiChatMessage-groupTimestamp | groupTimestamp | Class applied to the group timestamp element (compact variant only). |
| .MuiChatMessage-inlineMeta | inlineMeta | Styles applied to the inline meta container element (default variant). |
| .MuiChatMessage-inlineMetaSpacer | inlineMetaSpacer | Styles applied to the inline meta spacer element (default variant). |
| .MuiChatMessage-meta | meta | Styles applied to the message meta element. |
| .MuiChatMessage-roleAssistant | roleAssistant | Applied when the message role is 'assistant' |
| .MuiChatMessage-roleUser | roleUser | Applied when the message role is 'user' |
| .MuiChatMessage-root | root | Styles applied to the message root element. |
| .MuiChatMessage-streaming | streaming | Applied while the message is streaming |
You can override the style of the component using one of these customization options:
- With a global class name.
- With a rule name as part of the component's
styleOverridesproperty in a custom theme.
Source code
If you did not find the information in this page, consider having a look at the implementation of the component for more detail.