Skip to contentSkip to content

ChatComposer API

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

Demos

Import

import { ChatComposer } from '@mui/x-chat/ChatComposer';
// or
import { ChatComposer } from '@mui/x-chat';

Learn about the difference by reading this guide on minimizing bundle size.

Props

NameTypeDefaultDescription
attachmentConfig{ acceptedMimeTypes?: Array<string>, maxFileCount?: number, maxFileSize?: number, onAttachmentReject?: func }-

Configuration for attachment validation constraints. When provided, file attachments are validated against these rules.

classesPartial-

See CSS classes API below for more details.

disabledbool-
features{ attachments?: bool
| bool
| { acceptedMimeTypes?: Array<string>, maxFileCount?: number, maxFileSize?: number, onAttachmentReject?: func } }
-

Feature flags to control composer capabilities.

slotPropsComposerRootSlotProps-
slotsPartial-

See Slots API below for more details.

variant'compact'
| 'default'
'default'

The visual layout variant of the composer. - 'default' – Stacked layout: attachment list, textarea, then toolbar below. - 'compact' – Inline layout: start actions, textarea, end actions in a single row.

When omitted, inherits from the nearest ChatVariantProvider (e.g. set by ChatBox).

The component cannot hold a ref.

Slots

Slot nameClass nameDefault componentDescription
root.MuiChatComposer-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-disabledStyles applied to the root element when disabled.
.MuiChatComposer-attachButtonattachButtonStyles applied to the attach button element.
.MuiChatComposer-attachmentListattachmentListStyles applied to the attachment list element.
.MuiChatComposer-helperTexthelperTextStyles applied to the helper text element.
.MuiChatComposer-labellabelStyles applied to the input label element.
.MuiChatComposer-rootrootStyles applied to the input root element.
.MuiChatComposer-sendButtonsendButtonStyles applied to the send button element.
.MuiChatComposer-textAreatextAreaStyles applied to the textarea element.
.MuiChatComposer-toolbartoolbarStyles applied to the toolbar element.
.MuiChatComposer-variantCompactvariantCompactStyles applied to the root element when variant="compact".

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.