Skip to contentSkip to content

ChatBox API

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

Demos

Import

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

Override or extend the styles applied to the component.

See CSS classes API below for more details.

currentUser{ avatarUrl?: string, displayName?: string, id: string, isOnline?: bool, metadata?: object, role?: 'assistant'
| 'system'
| 'user' }
-

The local user sending messages. If omitted, derived from members by finding the entry with role === 'user'.

density'comfortable'
| 'compact'
| 'standard'
'standard'

The vertical spacing density of chat messages. - 'compact' – Reduced vertical spacing between messages. - 'standard' – Default spacing. - 'comfortable' – Increased vertical spacing between messages.

features{ attachments?: { acceptedMimeTypes?: Array<string>, maxFileCount?: number, maxFileSize?: number, onAttachmentReject?: func }
| bool, autoScroll?: { buffer?: number }
| bool, conversationHeader?: bool, helperText?: bool, scrollToBottom?: bool, suggestions?: bool }
-

Feature flags to enable or disable built-in ChatBox behaviours.

initialActiveConversationIdstring-

The initial active conversation ID when uncontrolled. Ignored after initialization and when activeConversationId is provided.

initialComposerValuestring-

The initial composer value when uncontrolled. Ignored after initialization and when composerValue is provided.

initialConversationsArray<{ avatarUrl?: string, id: string, lastMessageAt?: string, metadata?: object, participants?: Array<{ avatarUrl?: string, displayName?: string, id: string, isOnline?: bool, metadata?: object, role?: 'assistant'
| 'system'
| 'user' }>, readState?: 'read'
| 'unread', subtitle?: string, title?: string, unreadCount?: number }>
-

The initial conversations when uncontrolled. Ignored after initialization and when conversations is provided.

initialMessagesArray<{ author?: { avatarUrl?: string, displayName?: string, id: string, isOnline?: bool, metadata?: object, role?: 'assistant'
| 'system'
| 'user' }, conversationId?: string, createdAt?: string, editedAt?: string, id: string, metadata?: object, parts: Array<{ state?: 'done'
| 'streaming', text: string, type: 'text' }
| { state?: 'done'
| 'streaming', text: string, type: 'reasoning' }
| { filename?: string, mediaType: string, type: 'file', url: string }
| { sourceId: string, title?: string, type: 'source-url', url: string }
| { sourceId: string, text?: string, title?: string, type: 'source-document' }
| { data: any, id?: string, transient?: bool, type: object }
| { type: 'step-start' }
| { toolInvocation: { approval?: object, callProviderMetadata?: object, errorText?: string, input?: any, output?: any, preliminary?: bool, providerExecuted?: bool, state: 'approval-requested'
| 'approval-responded'
| 'input-available'
| 'input-streaming'
| 'output-available'
| 'output-denied'
| 'output-error', title?: string, toolCallId: string, toolName: string }, type: 'tool' }
| { toolInvocation: { approval?: object, callProviderMetadata?: object, errorText?: string, input?: any, output?: any, preliminary?: bool, providerExecuted?: bool, state: 'approval-requested'
| 'approval-responded'
| 'input-available'
| 'input-streaming'
| 'output-available'
| 'output-denied'
| 'output-error', title?: string, toolCallId: string, toolName: string }, type: 'dynamic-tool' }>, role: 'assistant'
| 'system'
| 'user', status?: 'cancelled'
| 'error'
| 'pending'
| 'read'
| 'sending'
| 'sent'
| 'streaming', updatedAt?: string }>
-

The initial messages when uncontrolled. Ignored after initialization and when messages is provided.

membersArray<{ avatarUrl?: string, displayName?: string, id: string, isOnline?: bool, metadata?: object, role?: 'assistant'
| 'system'
| 'user' }>
-

All participants in the chat. The current (local) user is derived as the first member with role === 'user', unless currentUser is provided explicitly.

slotPropsobject-

The extra props for the slot components.

slotsobject-

The components used for each slot inside the ChatBox.

See Slots API below for more details.

storeClassfuncChatStore

The store class to use for this provider.

streamFlushIntervalnumber16

Flush interval in milliseconds for batching rapid streaming deltas before applying them to the store.

suggestionsArray<{ label?: string, value: string }
| string>
-

Prompt suggestions displayed in the empty state. Clicking a suggestion pre-fills the composer.

suggestionsAutoSubmitboolfalse

Whether clicking a suggestion automatically submits the message.

variant'compact'
| 'default'
'default'

The visual layout variant of the chat. - 'default' – Standard layout with avatars, individual timestamps, and full spacing. - 'compact' – Messenger-style layout: no avatars, author + timestamp in group header, tighter spacing.

The component cannot hold a ref.

Slots

Slot nameClass nameDefault componentDescription
root.MuiChatBox-rootThe outermost container element. Defaults to div.
layout.MuiChatBox-layoutThe layout element that arranges conversations + thread panes. Defaults to div.
conversationsPane.MuiChatBox-conversationsPaneThe conversations pane container. Defaults to div.
threadPane.MuiChatBox-threadPaneThe thread pane container. Defaults to div.
conversationListOverride the conversation list component.
conversationHeaderOverride the conversation header component.
conversationTitleOverride the conversation title component.
conversationSubtitleOverride the conversation subtitle component.
conversationHeaderInfoOverride the conversation header info wrapper (title + subtitle column).
conversationHeaderActionsOverride the conversation header actions component.
messageListOverride the message list component.
messageRootOverride the message root component for each message.
messageAvatarOverride the message avatar component.
messageContentOverride the message content (bubble) component.
messageMetaOverride the message meta component.
messageActionsOverride the message actions component.
messageGroupOverride the message group component.
dateDividerOverride the date divider component.
composerRootOverride the composer (input) root component.
composerInputOverride the composer textarea component.
composerSendButtonOverride the composer send button.
composerAttachButtonOverride the composer attach button.
composerAttachmentListOverride the composer attachment list.
composerToolbarOverride the composer toolbar.
composerHelperTextOverride the composer helper text component.
typingIndicatorOverride the typing indicator component.
unreadMarkerOverride the unread marker component.
scrollToBottomOverride the scroll-to-bottom affordance component.
suggestionsOverride the prompt suggestions container component.

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.