ChatMessageContent API
API reference docs for the React ChatMessageContent component. Learn about the props, CSS, and other APIs of this exported module.
Demos
Import
import { ChatMessageContent } from '@mui/x-chat/ChatMessage';
// or
import { ChatMessageContent } from '@mui/x-chat';Learn about the difference by reading this guide on minimizing bundle size.
Props of the native component are also available.
| Name | Type | Description |
|---|---|---|
| afterContent | node | Content rendered inside the bubble after the message parts. Useful for placing inline metadata (e.g. timestamp, status) inside the bubble. |
| partProps | { dynamic-tool?: { className?: string, slotProps?: object, slots?: object, toolSlotProps?: object, toolSlots?: object }, file?: { className?: string, slotProps?: object, slots?: object }, reasoning?: { className?: string, slotProps?: object, slots?: object }, source-document?: { className?: string, slotProps?: object, slots?: object }, source-url?: { className?: string, slotProps?: object, slots?: object }, text?: { renderText?: func }, tool?: { className?: string, slotProps?: object, slots?: object, toolSlotProps?: object, toolSlots?: object } } | Props forwarded to the built-in unstyled part renderer components. Use this to pass |
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 | |
| .MuiChatMessageContent-actions | actions | Styles applied to the message actions element. |
| .MuiChatMessageContent-authorLabel | authorLabel | Styles applied to the message author label element. |
| .MuiChatMessageContent-avatar | avatar | Styles applied to the message avatar element. |
| .MuiChatMessageContent-bubble | bubble | Styles applied to the message bubble element inside content. |
| .MuiChatMessageContent-content | content | Styles applied to the message content element. |
| .MuiChatMessageContent-dateDivider | dateDivider | Styles applied to the date divider element. |
| .MuiChatMessageContent-group | group | Styles applied to the message group element. |
| .MuiChatMessageContent-groupAuthorName | groupAuthorName | Class applied to the group author name element. |
| .MuiChatMessageContent-groupTimestamp | groupTimestamp | Class applied to the group timestamp element (compact variant only). |
| .MuiChatMessageContent-inlineMeta | inlineMeta | Styles applied to the inline meta container element (default variant). |
| .MuiChatMessageContent-inlineMetaSpacer | inlineMetaSpacer | Styles applied to the inline meta spacer element (default variant). |
| .MuiChatMessageContent-meta | meta | Styles applied to the message meta element. |
| .MuiChatMessageContent-roleAssistant | roleAssistant | Applied when the message role is 'assistant' |
| .MuiChatMessageContent-roleUser | roleUser | Applied when the message role is 'user' |
| .MuiChatMessageContent-root | root | Styles applied to the message root element. |
| .MuiChatMessageContent-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.