Hello! I am styled using your active Material UI theme. Try sending a message.
Chat - Basic AI chat
The smallest working ChatBox setup: an adapter, a conversation, and an initial message.
This demo shows the minimum required props to render a styled, interactive chat surface using @mui/x-chat.
ChatBoxrendering a single conversation without a conversation listinitialConversationsandinitialMessagesfor initial stateinitialActiveConversationIdto open the conversation immediatelysxfor sizing the container
Press Enter to start editing
Why start here
This demo answers: "What is the smallest working @mui/x-chat surface?"
The answer is three things:
- An
adapterthat implementssendMessage - A
initialConversationsarray with at least one conversation - A
initialActiveConversationIdthat matches one of those conversations
Every other prop is optional.
The adapter
The demo uses a local echo adapter that echoes the user message back as a streaming response. In a real application, replace it with an adapter that calls your backend:
const adapter: ChatAdapter = {
async sendMessage({ message, signal }) {
const response = await fetch('/api/chat', {
method: 'POST',
body: JSON.stringify({ message }),
signal,
});
return response.body; // ReadableStream<ChatMessageChunk>
},
};
Implementation notes
- Keep the container height explicit so the message list and composer render correctly.
- Omitting
initialConversationsrenders an empty surface without a thread. - Omitting
initialActiveConversationIdshows the conversation list pane without an active thread.
See also
- Multi-conversation to add a conversation sidebar
- Customization for theme overrides, slots, and slotProps