Skip to contentSkip to content

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.

Props

NameTypeDescription
messageId*string
classesPartial

See CSS classes API below for more details.

isGroupedbool
slotPropsMessageRootSlotProps
slotsPartial

See Slots API below for more details.

The component cannot hold a ref.

Slots

Slot nameClass nameDefault componentDescription
root.MuiChatMessage-root

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
.MuiChatMessage-actionsactionsStyles applied to the message actions element.
.MuiChatMessage-authorLabelauthorLabelStyles applied to the message author label element.
.MuiChatMessage-avataravatarStyles applied to the message avatar element.
.MuiChatMessage-bubblebubbleStyles applied to the message bubble element inside content.
.MuiChatMessage-contentcontentStyles applied to the message content element.
.MuiChatMessage-dateDividerdateDividerStyles applied to the date divider element.
.MuiChatMessage-groupgroupStyles applied to the message group element.
.MuiChatMessage-groupAuthorNamegroupAuthorNameClass applied to the group author name element.
.MuiChatMessage-groupTimestampgroupTimestampClass applied to the group timestamp element (compact variant only).
.MuiChatMessage-inlineMetainlineMetaStyles applied to the inline meta container element (default variant).
.MuiChatMessage-inlineMetaSpacerinlineMetaSpacerStyles applied to the inline meta spacer element (default variant).
.MuiChatMessage-metametaStyles applied to the message meta element.
.MuiChatMessage-roleAssistantroleAssistantApplied when the message role is 'assistant'
.MuiChatMessage-roleUserroleUserApplied when the message role is 'user'
.MuiChatMessage-rootrootStyles applied to the message root element.
.MuiChatMessage-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.