Skip to contentSkip to content

ChatMessageGroup API

API reference docs for the React ChatMessageGroup component. Learn about the props, CSS, and other APIs of this exported module.

Demos

Import

import { ChatMessageGroup } from '@mui/x-chat/ChatMessage';
// or
import { ChatMessageGroup } 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.

NameTypeDefaultDescription
groupKeyfunc(message) => message.author?.id ?? message.role ?? ''

A function that maps a message to a group key. Messages that resolve to the same key are visually grouped (shared avatar, author name, etc.). Use createTimeWindowGroupKey(windowMs) to replicate time-window-based grouping.

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