Skip to contentSkip to content

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

Props of the native component are also available.

NameTypeDescription
afterContentnode

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 slots and slotProps to individual part type renderers.

The component cannot hold a ref.

CSS classes

These class names are useful for styling with CSS. They are applied to the component's slots when specific states are triggered.

Class nameRule nameDescription
.Mui-errorApplied when the message has an error status
.MuiChatMessageContent-actionsactionsStyles applied to the message actions element.
.MuiChatMessageContent-authorLabelauthorLabelStyles applied to the message author label element.
.MuiChatMessageContent-avataravatarStyles applied to the message avatar element.
.MuiChatMessageContent-bubblebubbleStyles applied to the message bubble element inside content.
.MuiChatMessageContent-contentcontentStyles applied to the message content element.
.MuiChatMessageContent-dateDividerdateDividerStyles applied to the date divider element.
.MuiChatMessageContent-groupgroupStyles applied to the message group element.
.MuiChatMessageContent-groupAuthorNamegroupAuthorNameClass applied to the group author name element.
.MuiChatMessageContent-groupTimestampgroupTimestampClass applied to the group timestamp element (compact variant only).
.MuiChatMessageContent-inlineMetainlineMetaStyles applied to the inline meta container element (default variant).
.MuiChatMessageContent-inlineMetaSpacerinlineMetaSpacerStyles applied to the inline meta spacer element (default variant).
.MuiChatMessageContent-metametaStyles applied to the message meta element.
.MuiChatMessageContent-roleAssistantroleAssistantApplied when the message role is 'assistant'
.MuiChatMessageContent-roleUserroleUserApplied when the message role is 'user'
.MuiChatMessageContent-rootrootStyles applied to the message root element.
.MuiChatMessageContent-streamingstreamingApplied while the message is streaming

You can override the style of the component using one of these customization options:

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.