본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Chat – 메시지

원문 보기 위키 갱신

Chat – 메시지 (Messages)

대화 기록을 가상화(virtualized)·그룹화되고 자동 스크롤되는 메시지 목록으로 렌더링해요.

출처: MUI X documentation

본문

인터랙티브 플레이그라운드 (Interactive playground)

하나의 ChatMessage 버블에서 role, status, density, grouping을 토글해 보세요:

import * as React from 'react';
import Box from '@mui/material/Box';
import Typography from '@mui/material/Typography';
import {
  ChatMessage as ChatMessageComponent,
  ChatMessageAvatar,
  ChatMessageContent,
  ChatMessageGroup,
} from '@mui/x-chat';
import type {
  ChatConversation,
  ChatDensity,
  ChatMessage,
  ChatVariant,
} from '@mui/x-chat/headless';
import { PlaygroundCard } from 'docs/src/modules/components/chat-playground/PlaygroundCard';
import {
  ChatChrome,
  MessageErrorEffect,
  ScopedChat,
} from 'docs/src/modules/components/chat-playground/sharedProviders';
import { sampleTexts } from 'docs/src/modules/components/chat-playground/sharedFixtures';
import {
  ChoiceControl,
  DividerLabel,
  SelectControl,
  SwitchControl,
} from 'docs/src/modules/components/chat-playground/controls';
import {
  useCustomizations,
  type CustomizationDef,
} from 'docs/src/modules/components/chat-playground/useCustomizations';
import { users } from 'docs/src/modules/components/chat-playground/data';

const conversation: ChatConversation = {
  id: 'msg-playground',
  title: 'Single message',
  participants: [users.me, users.assistant],
};

type Role = 'user' | 'assistant';
type StatusOption = 'sent' | 'read' | 'streaming' | 'error';
type LengthOption = 'short' | 'medium' | 'long' | 'markdown';

const DEFAULTS = {
  role: 'assistant' as Role,
  status: 'read' as StatusOption,
  length: 'medium' as LengthOption,
  variant: 'default' as ChatVariant,
  density: 'standard' as ChatDensity,
  grouped: false,
};

type ClassKey =
  'root' | 'bubble' | 'roleUser' | 'roleAssistant' | 'streaming' | 'error';

const CLASS_DEFS: ReadonlyArray<CustomizationDef<ClassKey>> = [
  { name: 'root', description: 'The message row.' },
  {
    name: 'bubble',
    selector: '.MuiChatMessage-bubble',
    description: 'The actual rounded bubble inside the content slot.',
  },
  {
    name: 'roleUser',
    selector: '.MuiChatMessage-roleUser',
    description: 'Applied to rows whose role is "user".',
  },
  {
    name: 'roleAssistant',
    selector: '.MuiChatMessage-roleAssistant',
    description: 'Applied to rows whose role is "assistant".',
  },
  {
    name: 'streaming',
    selector: '.MuiChatMessage-streaming',
    description: 'Applied while the message is streaming.',
  },
  {
    name: 'error',
    selector: '.MuiChatMessage-error',
    description: 'Applied when the message has an error status.',
  },
];

export default function ChatMessagePlayground() {
  const [role, setRole] = React.useState<Role>(DEFAULTS.role);
  const [status, setStatus] = React.useState<StatusOption>(DEFAULTS.status);
  const [length, setLength] = React.useState<LengthOption>(DEFAULTS.length);
  const [variant, setVariant] = React.useState<ChatVariant>(DEFAULTS.variant);
  const [density, setDensity] = React.useState<ChatDensity>(DEFAULTS.density);
  const [grouped, setGrouped] = React.useState(DEFAULTS.grouped);
  const classesCustomizations = useCustomizations<ClassKey>(CLASS_DEFS);

  const handleReset = React.useCallback(() => {
    setRole(DEFAULTS.role);
    setStatus(DEFAULTS.status);
    setLength(DEFAULTS.length);
    setVariant(DEFAULTS.variant);
    setDensity(DEFAULTS.density);
    setGrouped(DEFAULTS.grouped);
  }, []);

  const author = role === 'user' ? users.me : users.assistant;

  const message: ChatMessage = React.useMemo(
    () => ({
      id: 'msg-playground-bubble',
      conversationId: conversation.id,
      role,
      author,
      createdAt: '2026-05-03T09:30:00.000Z',
      status,
      parts: [{ type: 'text', text: sampleTexts[length] }],
    }),
    [role, author, status, length],
  );

  const messageSx = classesCustomizations.toClassesSx();

  return (
    <PlaygroundCard
      title="ChatMessage (bubble)"
      description="Single message bubble—toggle role, status, density, grouping."
      previewMinHeight={260}
      span={2}
      onReset={handleReset}
      classCustomizations={classesCustomizations.customizations}
      onClassesReset={classesCustomizations.reset}
      controls={
        <React.Fragment>
          <DividerLabel>props</DividerLabel>
          <SwitchControl
            label="isGrouped"
            checked={grouped}
            onChange={setGrouped}
            helperText="Render as a continuation of the previous bubble."
          />
          <DividerLabel>fixture (message data)</DividerLabel>
          <ChoiceControl<Role>
            label="role"
            value={role}
            options={['assistant', 'user'] as const}
            onChange={setRole}
            helperText="Stored on the message, read by useMessage()."
          />
          <SelectControl<StatusOption>
            label="status"
            value={status}
            options={[
              { value: 'sent' },
              { value: 'read' },
              { value: 'streaming' },
              { value: 'error' },
            ]}
            onChange={setStatus}
          />
          <SelectControl<LengthOption>
            label="content length"
            value={length}
            options={[
              { value: 'short' },
              { value: 'medium' },
              { value: 'long' },
              { value: 'markdown' },
            ]}
            onChange={setLength}
          />
          <DividerLabel>chrome provider</DividerLabel>
          <ChoiceControl<ChatVariant>
            label="ChatChrome.variant"
            value={variant}
            options={['default', 'compact'] as const}
            onChange={setVariant}
          />
          <ChoiceControl<ChatDensity>
            label="ChatChrome.density"
            value={density}
            options={['compact', 'standard', 'comfortable'] as const}
            onChange={setDensity}
          />
          <Typography variant="caption" color="text.secondary">
            variant and density mainly affect meta and bubble spacing—see the Meta
            and Inline meta playgrounds below.
          </Typography>
        </React.Fragment>
      }
      preview={
        <ScopedChat
          conversations={[conversation]}
          messages={[message]}
          activeConversationId={conversation.id}
        >
          <ChatChrome variant={variant} density={density}>
            <MessageErrorEffect
              messageId={message.id}
              enabled={status === 'error'}
            />
            <Box sx={{ width: '100%' }}>
              <ChatMessageGroup messageId={message.id}>
                <ChatMessageComponent
                  messageId={message.id}
                  isGrouped={grouped}
                  sx={messageSx}
                >
                  <ChatMessageAvatar />
                  <ChatMessageContent />
                </ChatMessageComponent>
              </ChatMessageGroup>
            </Box>
          </ChatChrome>
        </ScopedChat>
      }
    />
  );
}

그룹 플레이그라운드 (Group playground)

ChatMessageGroup은 같은 작성자의 연속된 메시지들을 하나의 시각적 클러스터로 접어요:

import * as React from 'react';
import Box from '@mui/material/Box';
import {
  ChatMessage as ChatMessageComponent,
  ChatMessageAvatar,
  ChatMessageContent,
  ChatMessageGroup,
} from '@mui/x-chat';
import type {
  ChatConversation,
  ChatDensity,
  ChatMessage,
  ChatVariant,
} from '@mui/x-chat/headless';
import { PlaygroundCard } from 'docs/src/modules/components/chat-playground/PlaygroundCard';
import {
  ChatChrome,
  ScopedChat,
} from 'docs/src/modules/components/chat-playground/sharedProviders';
import {
  ChoiceControl,
  DividerLabel,
  NumberControl,
  SwitchControl,
} from 'docs/src/modules/components/chat-playground/controls';
import { users } from 'docs/src/modules/components/chat-playground/data';

const conversation: ChatConversation = {
  id: 'group-playground',
  title: 'Grouped messages',
  participants: [users.me, users.assistant],
};

const sampleSnippets = [
  'Three quick notes on theming.',
  'First—the avatar only renders for the first message in a group.',
  'Second—bubbles tighten vertically when grouped.',
  'Third—the meta line stays attached to the last bubble.',
  'Bonus—try toggling the variant on the right.',
];

const DEFAULTS = {
  count: 3,
  author: 'assistant' as const,
  variant: 'default' as ChatVariant,
  density: 'standard' as ChatDensity,
  interleave: false,
};

export default function ChatMessageGroupPlayground() {
  const [count, setCount] = React.useState(DEFAULTS.count);
  const [author, setAuthor] = React.useState<'assistant' | 'user'>(DEFAULTS.author);
  const [variant, setVariant] = React.useState<ChatVariant>(DEFAULTS.variant);
  const [density, setDensity] = React.useState<ChatDensity>(DEFAULTS.density);
  const [interleave, setInterleave] = React.useState(DEFAULTS.interleave);

  const handleReset = React.useCallback(() => {
    setCount(DEFAULTS.count);
    setAuthor(DEFAULTS.author);
    setVariant(DEFAULTS.variant);
    setDensity(DEFAULTS.density);
    setInterleave(DEFAULTS.interleave);
  }, []);

  const messages: ChatMessage[] = React.useMemo(() => {
    const created = Date.UTC(2026, 4, 3, 10, 0, 0);
    const flippedAuthor = author === 'assistant' ? 'user' : 'assistant';
    return Array.from({ length: count }, (_, i) => {
      const altAuthor = interleave && i % 2 === 1 ? flippedAuthor : author;
      const messageAuthor = altAuthor === 'user' ? users.me : users.assistant;
      return {
        id: `group-msg-${i}`,
        conversationId: conversation.id,
        role: altAuthor,
        author: messageAuthor,
        createdAt: new Date(created + i * 30_000).toISOString(),
        status: 'read',
        parts: [{ type: 'text', text: sampleSnippets[i % sampleSnippets.length] }],
      } as ChatMessage;
    });
  }, [count, author, interleave]);
  return (
    <PlaygroundCard
      title="ChatMessageGroup"
      description="Wraps consecutive messages from the same author into a visual cluster."
      previewMinHeight={300}
      span={2}
      onReset={handleReset}
      controls={
        <React.Fragment>
          <DividerLabel>fixture data</DividerLabel>
          <NumberControl
            label="message count"
            value={count}
            min={1}
            max={5}
            onChange={setCount}
          />
          <ChoiceControl<'assistant' | 'user'>
            label="author"
            value={author}
            options={['assistant', 'user'] as const}
            onChange={setAuthor}
          />
          <SwitchControl
            label="interleave authors"
            checked={interleave}
            onChange={setInterleave}
            helperText="Alternate authors so groups break."
          />
          <DividerLabel>chrome provider</DividerLabel>
          <ChoiceControl<ChatVariant>
            label="ChatChrome.variant"
            value={variant}
            options={['default', 'compact'] as const}
            onChange={setVariant}
          />
          <ChoiceControl<ChatDensity>
            label="ChatChrome.density"
            value={density}
            options={['compact', 'standard', 'comfortable'] as const}
            onChange={setDensity}
          />
        </React.Fragment>
      }
      preview={
        <ScopedChat
          conversations={[conversation]}
          messages={messages}
          activeConversationId={conversation.id}
        >
          <ChatChrome variant={variant} density={density}>
            <Box sx={{ width: '100%' }}>
              {messages.map((message) => (
                <ChatMessageGroup key={message.id} messageId={message.id}>
                  <ChatMessageComponent messageId={message.id}>
                    <ChatMessageAvatar />
                    <ChatMessageContent />
                  </ChatMessageComponent>
                </ChatMessageGroup>
              ))}
            </Box>
          </ChatChrome>
        </ScopedChat>
      }
    />
  );
}

목록 플레이그라운드 (List playground)

ChatMessageList는 렌더링을 가상화하고, 자동 스크롤을 관리하며, 날짜 사이 선택적 구분선(divider)을 넣을 수 있어요:

import * as React from 'react';
import Box from '@mui/material/Box';
import Typography from '@mui/material/Typography';
import { ChatMessageList } from '@mui/x-chat';
import type {
  ChatConversation,
  ChatDensity,
  ChatMessage,
  ChatVariant,
} from '@mui/x-chat/headless';
import { PlaygroundCard } from 'docs/src/modules/components/chat-playground/PlaygroundCard';
import {
  ChatChrome,
  ScopedChat,
} from 'docs/src/modules/components/chat-playground/sharedProviders';
import {
  ChoiceControl,
  DividerLabel,
  NumberControl,
  SwitchControl,
} from 'docs/src/modules/components/chat-playground/controls';
import {
  useCustomizations,
  type CustomizationDef,
} from 'docs/src/modules/components/chat-playground/useCustomizations';
import { users } from 'docs/src/modules/components/chat-playground/data';

const conversation: ChatConversation = {
  id: 'list-playground',
  title: 'Message list',
  participants: [users.me, users.assistant, users.alice],
};

function buildMessages(messageCount: number, spanDays: boolean): ChatMessage[] {
  const baseDay = Date.UTC(2026, 4, 3, 9, 0, 0);
  const dayMs = 24 * 60 * 60 * 1000;
  const authorRotation = [users.alice, users.assistant, users.me];
  return Array.from({ length: messageCount }, (_, i) => {
    const author = authorRotation[i % authorRotation.length];
    const role = author === users.assistant ? 'assistant' : 'user';
    const dayOffset = spanDays
      ? Math.floor(i / Math.max(1, Math.ceil(messageCount / 3)))
      : 0;
    const created = baseDay - dayOffset * dayMs + (i % 6) * 60_000;
    return {
      id: `list-msg-${i}`,
      conversationId: conversation.id,
      role,
      author,
      createdAt: new Date(created).toISOString(),
      status: 'read',
      parts: [
        {
          type: 'text',
          text: `Message ${i + 1} from ${author.displayName}.`,
        },
      ],
    } as ChatMessage;
  }).reverse();
}

const DEFAULTS = {
  count: 8,
  spanDays: true,
  dateDivider: true,
  autoScroll: true,
  autoScrollBuffer: 150,
  showOverlay: false,
  variant: 'default' as ChatVariant,
  density: 'standard' as ChatDensity,
};

type ClassKey = 'root' | 'scroller' | 'content';

const CLASS_DEFS: ReadonlyArray<CustomizationDef<ClassKey>> = [
  { name: 'root', description: 'The root list element.' },
  {
    name: 'scroller',
    selector: '.MuiChatMessageList-scroller',
    description: 'Scroller wrapper.',
  },
  {
    name: 'content',
    selector: '.MuiChatMessageList-content',
    description: 'Inner content area.',
  },
];

export default function ChatMessageListPlayground() {
  const [count, setCount] = React.useState(DEFAULTS.count);
  const [spanDays, setSpanDays] = React.useState(DEFAULTS.spanDays);
  const [dateDivider, setDateDivider] = React.useState(DEFAULTS.dateDivider);
  const [autoScroll, setAutoScroll] = React.useState(DEFAULTS.autoScroll);
  const [autoScrollBuffer, setAutoScrollBuffer] = React.useState(
    DEFAULTS.autoScrollBuffer,
  );
  const [showOverlay, setShowOverlay] = React.useState(DEFAULTS.showOverlay);
  const [variant, setVariant] = React.useState<ChatVariant>(DEFAULTS.variant);
  const [density, setDensity] = React.useState<ChatDensity>(DEFAULTS.density);
  const classesCustomizations = useCustomizations<ClassKey>(CLASS_DEFS);

  const handleReset = React.useCallback(() => {
    setCount(DEFAULTS.count);
    setSpanDays(DEFAULTS.spanDays);
    setDateDivider(DEFAULTS.dateDivider);
    setAutoScroll(DEFAULTS.autoScroll);
    setAutoScrollBuffer(DEFAULTS.autoScrollBuffer);
    setShowOverlay(DEFAULTS.showOverlay);
    setVariant(DEFAULTS.variant);
    setDensity(DEFAULTS.density);
  }, []);

  const messages = React.useMemo(
    () => buildMessages(count, spanDays),
    [count, spanDays],
  );

  let autoScrollValue: boolean | { buffer: number };
  if (!autoScroll) {
    autoScrollValue = false;
  } else if (autoScrollBuffer === DEFAULTS.autoScrollBuffer) {
    autoScrollValue = true;
  } else {
    autoScrollValue = { buffer: autoScrollBuffer };
  }

  const overlay = showOverlay ? (
    <Box
      sx={(theme) => ({
        position: 'absolute',
        inset: theme.spacing(1),
        display: 'flex',
        alignItems: 'flex-start',
        justifyContent: 'flex-end',
        pointerEvents: 'none',
      })}
    >
      <Box
        sx={(theme) => ({
          pointerEvents: 'auto',
          padding: theme.spacing(0.5, 1.25),
          borderRadius: 16,
          bgcolor: 'background.paper',
          border: '1px solid',
          borderColor: 'divider',
          boxShadow: theme.shadows[1],
        })}
      >
        <Typography variant="caption" color="text.secondary">
          overlay slot
        </Typography>
      </Box>
    </Box>
  ) : null;

  const listSx = classesCustomizations.toClassesSx();
  return (
    <PlaygroundCard
      title="ChatMessageList"
      description="Virtualised scroller with auto-scroll, opt-in date dividers and an overlay slot."
      previewMinHeight={360}
      span={2}
      onReset={handleReset}
      classCustomizations={classesCustomizations.customizations}
      onClassesReset={classesCustomizations.reset}
      controls={
        <React.Fragment>
          <DividerLabel>props</DividerLabel>
          <SwitchControl
            label="autoScroll"
            checked={autoScroll}
            onChange={setAutoScroll}
            helperText="Stick to the bottom on new messages."
          />
          <NumberControl
            label="autoScroll buffer"
            value={autoScrollBuffer}
            min={0}
            max={500}
            step={10}
            disabled={!autoScroll}
            valueFormatter={(value) => `${value}px`}
            helperText="Distance from bottom to still trigger auto-scroll."
            onChange={setAutoScrollBuffer}
          />
          <SwitchControl
            label="features.dateDivider"
            checked={dateDivider}
            onChange={setDateDivider}
            helperText="Opt-in day separators between calendar days."
          />
          <SwitchControl
            label="overlay"
            checked={showOverlay}
            onChange={setShowOverlay}
            helperText="Demos the `overlay` slot for empty-state UI."
          />
          <DividerLabel>fixture data</DividerLabel>
          <NumberControl
            label="message count"
            value={count}
            min={1}
            max={40}
            onChange={setCount}
          />
          <SwitchControl
            label="span multiple days"
            checked={spanDays}
            onChange={setSpanDays}
            helperText="Creates the day boundaries the divider renders at."
          />
          <DividerLabel>chrome provider</DividerLabel>
          <ChoiceControl<ChatVariant>
            label="ChatChrome.variant"
            value={variant}
            options={['default', 'compact'] as const}
            onChange={setVariant}
          />
          <ChoiceControl<ChatDensity>
            label="ChatChrome.density"
            value={density}
            options={['compact', 'standard', 'comfortable'] as const}
            onChange={setDensity}
          />
        </React.Fragment>
      }
      preview={
        <ScopedChat
          conversations={[conversation]}
          messages={messages}
          activeConversationId={conversation.id}
        >
          <ChatChrome variant={variant} density={density}>
            <Box
              sx={{
                width: '100%',
                height: 360,
                overflow: 'hidden',
                display: 'flex',
                position: 'relative',
              }}
            >
              <ChatMessageList
                items={messages.map((m) => m.id)}
                autoScroll={autoScrollValue}
                overlay={overlay}
                features={{ dateDivider }}
                sx={listSx}
              />
            </Box>
          </ChatChrome>
        </ScopedChat>
      }
    />
  );
}

ChatMessage 데이터 모델 (The ChatMessage data model)

채팅 시스템의 모든 메시지는 ChatMessage 인터페이스로 표현돼요:

import type { ChatMessage } from '@mui/x-chat/headless';

ChatMessage는 다음과 같은 형태를 가져요:

Field Type Description
id string 메시지의 고유 식별자
role ChatRole 'user', 'assistant', 또는 'system'
parts ChatMessagePart[] 메시지 본문을 구성하는 콘텐츠 파츠(text, files, tools 등)
status ChatMessageStatus 전달 수명주기: 'pending', 'sending', 'streaming', 'sent', 'read', 'error', 또는 'cancelled'
author ChatUser 인라인 신원 데이터와 멤버 매칭에 사용되는 작성자 payload
createdAt string 메시지가 생성된 ISO 8601 타임스탬프
updatedAt string 메시지가 마지막으로 업데이트된 ISO 8601 타임스탬프
editedAt string 메시지가 편집된 경우의 ISO 8601 타임스탬프
conversationId string 이 메시지가 속한 대화
metadata ChatMessageMetadata 커스텀 데이터를 위한 확장 가능한 메타데이터 객체

author.id는 메시지 렌더링을 위한 정식 신원 키예요. members, currentUser, 또는 활성 대화의 participants를 전달하면, 채팅 컴포넌트들은 그 id를 사용해 렌더링 시 누락된 표시 이름과 아바타를 보강해요.

메시지 모델이 작성자 신원을 다른 곳에 저장한다면 ChatProvider, ChatRoot, 또는 ChatBox에 getMessageAuthorId, getMessageAuthorDisplayName, getMessageAuthorAvatarUrl을 제공해 그 데이터를 내장 메시지 프리미티브에 매핑할 수 있어요.

메시지 파츠 (Message parts)

parts 배열은 핵심 콘텐츠 모델이에요. 각 파츠는 렌더링 방식을 결정하는 type 판별자(discriminant)를 가져요:

Part type Description
text 일반 텍스트 또는 마크다운 텍스트 콘텐츠
reasoning 모델 추론 / 사고 과정(chain-of-thought) 텍스트
file 첨부된 파일(이미지, 문서 등)
source-url URL 인용
source-document 문서 인용
tool 도구 호출과 그 결과
step-start 에이전트 단계 사이의 시각적 구분선

이 파츠 기반 모델 덕분에 하나의 메시지가 혼합 콘텐츠를 포함할 수 있어요. 예를 들어 텍스트 설명 다음에 코드 블록과 출처 인용이 이어질 수 있어요.

메시지 상태 수명주기 (Message status lifecycle)

메시지는 상태 수명주기를 거쳐 진행돼요:

pending → sending → streaming → sent → read
                 \→ error
                 \→ cancelled
  • pending — 메시지가 큐에 있지만 아직 어댑터로 전달되지 않았어요.
  • sending — 메시지가 전달되었고, 첫 번째 응답 청크를 기다리고 있어요.
  • streaming — 어시스턴트가 토큰을 적극적으로 생성하고 있어요.
  • sent — 응답이 완료되었어요.
  • read — 수신자가 메시지를 보았어요. 런타임은 이 상태를 절대 추론하지 않아요. 데이터 소스나 어댑터에서 제공해 주세요. meta 슬롯은 이를 이중 체크표시로 렌더링해요.
  • error — 어댑터에서 오류가 발생했어요.
  • cancelled — 사용자 또는 애플리케이션이 응답을 취소했어요.

가져오기 (Import)

import { ChatMessageList, ChatMessageGroup, ChatMessage } from '@mui/x-chat';

:::info ChatBox를 사용할 때는 메시지 목록이 이미 구성의 내장 부분으로 포함돼요. 커스텀 레이아웃을 만들 때만 이 컴포넌트들을 직접 가져오면 돼요. ChatMessage는 복합(compound) 행 컴포넌트예요. 그 렌더링 표면은 아래 슬롯 컴포넌트들(Avatar, Author label, Content, Meta, Inline meta)을 통해 구성되며, 각각 고유한 API 페이지를 가져요. :::

컴포넌트 구조 (Component anatomy)

ChatBox 안에서 메시지 목록은 테마가 적용된 컴포넌트들의 하위 트리를 렌더링해요:

ChatMessageList                     ← scrollable container
  MessageListDateDivider            ← date separator between message groups (opt-in)
  ChatMessageGroup                  ← groups consecutive same-author messages
    ChatMessage                     ← individual message row
      ChatMessageAvatar             ← author avatar
      ChatMessageContent            ← message bubble with part renderers
      ChatMessageMeta               ← timestamp, delivery status
      ChatMessageActions            ← hover action buttons

메시지가 렌더링되는 방식 (How messages render)

ChatMessageList 컴포넌트는 대화 기록을 렌더링하는 스크롤 가능한 영역이에요. 기본적으로 스크롤 동작, 오버플로, 패딩, 그리고 얇은 스크롤바를 관리해요.

메시지 그룹 (Message groups)

같은 작성자의 연속된 메시지들은 하나의 ChatMessageGroup으로 묶여요. 그룹 안에서는 첫 번째 메시지만 아바타를 표시해 시각적 반복을 줄이고 대화를 더 쉽게 훑어볼 수 있게 해요. 메시지 작성자에 대한 표시 이름이나 아바타가 없으면, 역할 이름으로 폴백하는 대신 해당 표시 기능을 생략해요.

그룹 구성과 데모는 Message appearance를 참고해요.

날짜 구분선 (Date dividers)

연속된 메시지가 다른 달력 날짜에 걸쳐 있으면, 메시지 목록은 그 사이에 날짜 구분선을 렌더링할 수 있어요. 구분선은 기본적으로 비활성화되어 있어요 — dateDivider 기능 플래그로 활성화해요:

<ChatBox adapter={adapter} features={{ dateDivider: true }} />

커스터마이즈는 Date divider와 Message appearance를 참고해요.

자동 스크롤 (Auto-scrolling)

메시지 목록은 사용자가 새 메시지를 보내거나, 새 어시스턴트 메시지가 도착하거나, 스트리밍 중일 때 자동으로 바닥으로 스크롤돼요.

버퍼 구성과 스크롤-투-바닥 기능은 Scrolling을 참고해요.

접근성 (Accessibility)

메시지 목록은 단일 Tab 정지점이에요. role="article" 메시지 위의 순환 tabindex(roving tabindex) 덕분에 한 번에 하나의 메시지만 탭 순서에 포함되어, 페이지를 탭으로 이동할 때 모든 메시지를 하나씩 지나가지 않아요.

  • Arrow Up / Arrow Down과 Home / End로 메시지 사이를 이동해요.
  • Enter는 포커스된 메시지의 링크, 복사 버튼, 액션으로 들어가고, Escape는 메시지로 돌아와요.
  • 스크롤러는 role="log" 정중한(polite) live region이며, 시각적으로 숨겨진 role="status" 영역은 스트리밍 전환("Assistant is responding" / "Response complete")을 각각 정확히 한 번씩 알려줘요.
  • 스레드, 컴포저, 대화 목록은 라벨이 지정된 랜드마크로 노출돼요.
'use client';
import * as React from 'react';
import Box from '@mui/material/Box';
import Typography from '@mui/material/Typography';
import { ChatBox } from '@mui/x-chat';
import { createEchoAdapter } from 'docs/data/chat/core/examples/shared/demoUtils';
import {
  createTextMessage,
  demoUsers,
  minimalConversation,
} from 'docs/data/chat/core/examples/shared/demoData';

const adapter = createEchoAdapter();

const conversationId = minimalConversation.id;

const messages = [
  createTextMessage({
    id: 'kbd-msg-1',
    conversationId,
    role: 'user',
    author: demoUsers.you,
    createdAt: '2026-03-15T09:50:00.000Z',
    text: 'How do I move around this chat with the keyboard?',
  }),
  createTextMessage({
    id: 'kbd-msg-2',
    conversationId,
    role: 'assistant',
    author: demoUsers.agent,
    createdAt: '2026-03-15T09:51:00.000Z',
    text: 'The message list is a single Tab stop — Arrow Up and Arrow Down move between messages.',
  }),
  createTextMessage({
    id: 'kbd-msg-3',
    conversationId,
    role: 'user',
    author: demoUsers.you,
    createdAt: '2026-03-15T09:52:00.000Z',
    text: 'And how do I reach a link or a copy button inside a message?',
  }),
  createTextMessage({
    id: 'kbd-msg-4',
    conversationId,
    role: 'assistant',
    author: demoUsers.agent,
    createdAt: '2026-03-15T09:53:00.000Z',
    text: [
      'Press Enter on the focused message to drill into its controls, and Escape to come back.',
      'Try it here — this message has [a link](https://mui.com/x/react-chat/) and a code block:',
      '',
      '```ts',
      "import { ChatBox } from '@mui/x-chat';",
      '```',
    ].join('\n'),
  }),
  createTextMessage({
    id: 'kbd-msg-5',
    conversationId,
    role: 'assistant',
    author: demoUsers.agent,
    createdAt: '2026-03-15T09:54:00.000Z',
    text: 'Home and End jump to the first and latest message, and Page Up/Page Down scroll natively so long messages stay readable.',
  }),
];

export default function KeyboardNavigation() {
  return (
    <Box sx={{ width: '100%', maxWidth: 560, mx: 'auto' }}>
      <Typography
        color="text.secondary"
        sx={{ mb: 1 }}
        variant="caption"
        component="p"
      >
        Tab into the list (a single stop), Arrow Up/Down between messages, Enter to
        drill into the focused message&apos;s links and buttons, Escape to come back,
        Tab onward to the composer.
      </Typography>
      <ChatBox
        adapter={adapter}
        initialActiveConversationId={conversationId}
        initialConversations={[minimalConversation]}
        initialMessages={messages}
        sx={{
          height: 420,
          border: '1px solid',
          borderColor: 'divider',
          borderRadius: 1,
        }}
      />
    </Box>
  );
}

메시지 목록의 enableRovingFocus={false}를 설정해 이 동작을 끌 수 있고, @mui/x-chat/headless의 useMessageContentTabIndex() 훅을 사용해 커스텀 인터랙티브 콘텐츠가 참여하게 할 수 있어요.

드릴-인 수명주기, 목록별 포커스 메모리, locale 키를 포함한 전체 모델은 Accessibility 페이지와 Message list—Accessibility에서 확인할 수 있어요.

독립 사용 (Standalone usage)

ChatBox 밖에서 커스텀 레이아웃을 만들 때는 ChatProvider 안의 ChatConversation 안에서 ChatMessageList를 렌더링해요. 아래 데모는 프로바이더, 활성 대화 범위, 경계가 정해진 프레임, 메시지 목록 구성만으로 메시지 표면을 분리해 보여줘요:

'use client';
import * as React from 'react';
import Box from '@mui/material/Box';
import { ChatConversation, ChatMessageList } from '@mui/x-chat';
import { ChatProvider } from '@mui/x-chat/headless';
import { createEchoAdapter } from 'docs/data/chat/core/examples/shared/demoUtils';
import {
  minimalConversation,
  minimalMessages,
} from 'docs/data/chat/core/examples/shared/demoData';

const adapter = createEchoAdapter();

export default function StandaloneMessages() {
  return (
    <ChatProvider
      adapter={adapter}
      initialActiveConversationId={minimalConversation.id}
      initialConversations={[minimalConversation]}
      initialMessages={minimalMessages}
    >
      <Box
        sx={{
          height: 400,
          overflow: 'hidden',
        }}
      >
        <ChatConversation>
          <ChatMessageList />
        </ChatConversation>
      </Box>
    </ChatProvider>
  );
}

메시지 슬롯 (Message slots)

ChatMessage 행 안의 각 슬롯은 고유한 플레이그라운드를 가져요. 한 번에 한 표면씩 반복해 보세요.

Avatar

작성자 아바타 슬롯 — avatarUrl이 설정되지 않으면 이니셜로 폴백해요.

import * as React from 'react';
import Box from '@mui/material/Box';
import {
  ChatMessage as ChatMessageComponent,
  ChatMessageAvatar,
  ChatMessageContent,
  ChatMessageGroup,
} from '@mui/x-chat';
import type {
  ChatConversation,
  ChatMessage,
  ChatVariant,
} from '@mui/x-chat/headless';
import { PlaygroundCard } from 'docs/src/modules/components/chat-playground/PlaygroundCard';
import {
  ChatChrome,
  ScopedChat,
} from 'docs/src/modules/components/chat-playground/sharedProviders';
import {
  ChoiceControl,
  DividerLabel,
} from 'docs/src/modules/components/chat-playground/controls';
import {
  useCustomizations,
  type CustomizationDef,
} from 'docs/src/modules/components/chat-playground/useCustomizations';
import { users } from 'docs/src/modules/components/chat-playground/data';

const conversation: ChatConversation = {
  id: 'avatar-playground',
  title: 'Parts',
  participants: [users.me, users.assistant],
};

type Role = 'assistant' | 'user';
type Status = 'sent' | 'read' | 'streaming';

function makeMessage(role: Role, status: Status, text: string): ChatMessage {
  const author = role === 'user' ? users.me : users.assistant;
  return {
    id: `avatar-${role}-${status}`,
    conversationId: conversation.id,
    role,
    author,
    createdAt: '2026-05-03T09:30:00.000Z',
    status,
    parts: [{ type: 'text', text }],
  };
}

type ClassKey = 'avatar';

const CLASS_DEFS: ReadonlyArray<CustomizationDef<ClassKey>> = [
  {
    name: 'avatar',
    selector: '.MuiChatMessage-avatar',
    description: 'Applied to the avatar element of the message row.',
  },
];

export default function ChatMessageAvatarPlayground() {
  const [role, setRole] = React.useState<Role>('assistant');
  const [variant, setVariant] = React.useState<ChatVariant>('default');
  const classesCustomizations = useCustomizations<ClassKey>(CLASS_DEFS);

  const message = React.useMemo(
    () => makeMessage(role, 'read', 'Avatar preview message.'),
    [role],
  );

  const avatarSx = classesCustomizations.toClassesSx();

  return (
    <PlaygroundCard
      title="ChatMessageAvatar"
      description="Author avatar slot—falls back to initials when no avatarUrl is set."
      previewMinHeight={120}
      classCustomizations={classesCustomizations.customizations}
      onClassesReset={classesCustomizations.reset}
      controls={
        <React.Fragment>
          <DividerLabel>fixture (message data)</DividerLabel>
          <ChoiceControl<Role>
            label="role"
            value={role}
            options={['assistant', 'user'] as const}
            onChange={setRole}
          />
          <DividerLabel>chrome provider</DividerLabel>
          <ChoiceControl<ChatVariant>
            label="ChatChrome.variant"
            value={variant}
            options={['default', 'compact'] as const}
            onChange={setVariant}
          />
        </React.Fragment>
      }
      preview={
        <ScopedChat
          conversations={[conversation]}
          messages={[message]}
          activeConversationId={conversation.id}
        >
          <ChatChrome variant={variant} density="standard">
            <Box sx={{ width: '100%', ...avatarSx }}>
              <ChatMessageGroup messageId={message.id}>
                <ChatMessageComponent messageId={message.id}>
                  <ChatMessageAvatar />
                  <ChatMessageContent />
                </ChatMessageComponent>
              </ChatMessageGroup>
            </Box>
          </ChatChrome>
        </ScopedChat>
      }
    />
  );
}

작성자 라벨 (Author label)

그룹화된 메시지 위에 작성자 이름을 표시해요.

import * as React from 'react';
import Box from '@mui/material/Box';
import {
  ChatMessage as ChatMessageComponent,
  ChatMessageAuthorLabel,
  ChatMessageGroup,
} from '@mui/x-chat';
import type { ChatConversation, ChatMessage } from '@mui/x-chat/headless';
import { PlaygroundCard } from 'docs/src/modules/components/chat-playground/PlaygroundCard';
import { ScopedChat } from 'docs/src/modules/components/chat-playground/sharedProviders';
import {
  ChoiceControl,
  DividerLabel,
} from 'docs/src/modules/components/chat-playground/controls';
import {
  useCustomizations,
  type CustomizationDef,
} from 'docs/src/modules/components/chat-playground/useCustomizations';
import { users } from 'docs/src/modules/components/chat-playground/data';

const conversation: ChatConversation = {
  id: 'author-label-playground',
  title: 'Parts',
  participants: [users.me, users.assistant],
};

type Role = 'assistant' | 'user';
type Status = 'sent' | 'read' | 'streaming';

function makeMessage(role: Role, status: Status, text: string): ChatMessage {
  const author = role === 'user' ? users.me : users.assistant;
  return {
    id: `author-label-${role}-${status}`,
    conversationId: conversation.id,
    role,
    author,
    createdAt: '2026-05-03T09:30:00.000Z',
    status,
    parts: [{ type: 'text', text }],
  };
}

type ClassKey = 'authorLabel';

const CLASS_DEFS: ReadonlyArray<CustomizationDef<ClassKey>> = [
  {
    name: 'authorLabel',
    selector: '.MuiChatMessage-authorLabel',
    description: 'Applied to the author label element above the bubble group.',
  },
];

export default function ChatMessageAuthorLabelPlayground() {
  const [role, setRole] = React.useState<Role>('assistant');
  const classesCustomizations = useCustomizations<ClassKey>(CLASS_DEFS);

  const message = React.useMemo(
    () => makeMessage(role, 'read', 'Author label preview message.'),
    [role],
  );

  const labelSx = classesCustomizations.toClassesSx();

  return (
    <PlaygroundCard
      title="ChatMessageAuthorLabel"
      description="Author display name rendered above grouped messages."
      previewMinHeight={96}
      classCustomizations={classesCustomizations.customizations}
      onClassesReset={classesCustomizations.reset}
      controls={
        <React.Fragment>
          <DividerLabel>fixture (message data)</DividerLabel>
          <ChoiceControl<Role>
            label="role"
            value={role}
            options={['assistant', 'user'] as const}
            onChange={setRole}
          />
        </React.Fragment>
      }
      preview={
        <ScopedChat
          conversations={[conversation]}
          messages={[message]}
          activeConversationId={conversation.id}
        >
          <Box sx={{ width: '100%', ...labelSx }}>
            <ChatMessageGroup messageId={message.id}>
              <ChatMessageComponent messageId={message.id}>
                <ChatMessageAuthorLabel />
              </ChatMessageComponent>
            </ChatMessageGroup>
          </Box>
        </ScopedChat>
      }
    />
  );
}

콘텐츠 (Content)

버블 내부 — 마크다운, 코드 펜스, 도구 또는 출처 파츠를 렌더링해요.

import * as React from 'react';
import Box from '@mui/material/Box';
import {
  ChatMessage as ChatMessageComponent,
  ChatMessageAvatar,
  ChatMessageContent,
  ChatMessageGroup,
} from '@mui/x-chat';
import type {
  ChatConversation,
  ChatMessage,
  ChatVariant,
} from '@mui/x-chat/headless';
import { PlaygroundCard } from 'docs/src/modules/components/chat-playground/PlaygroundCard';
import {
  ChatChrome,
  ScopedChat,
} from 'docs/src/modules/components/chat-playground/sharedProviders';
import {
  ChoiceControl,
  DividerLabel,
  SelectControl,
} from 'docs/src/modules/components/chat-playground/controls';
import {
  useCustomizations,
  type CustomizationDef,
} from 'docs/src/modules/components/chat-playground/useCustomizations';
import { users } from 'docs/src/modules/components/chat-playground/data';

const conversation: ChatConversation = {
  id: 'content-playground',
  title: 'Parts',
  participants: [users.me, users.assistant],
};

type Role = 'assistant' | 'user';
type Status = 'sent' | 'read' | 'streaming';

function makeMessage(role: Role, status: Status, text: string): ChatMessage {
  const author = role === 'user' ? users.me : users.assistant;
  return {
    id: `content-${role}-${status}`,
    conversationId: conversation.id,
    role,
    author,
    createdAt: '2026-05-03T09:30:00.000Z',
    status,
    parts: [{ type: 'text', text }],
  };
}

type ClassKey = 'content' | 'bubble';

const CLASS_DEFS: ReadonlyArray<CustomizationDef<ClassKey>> = [
  {
    name: 'content',
    selector: '.MuiChatMessage-content',
    description: 'The content slot wrapping the bubble + inline meta.',
  },
  {
    name: 'bubble',
    selector: '.MuiChatMessage-bubble',
    description: 'The actual rounded bubble element.',
  },
];

export default function ChatMessageContentPlayground() {
  const [content, setContent] = React.useState<'plain' | 'markdown'>('markdown');
  const [role, setRole] = React.useState<Role>('assistant');
  const [variant, setVariant] = React.useState<ChatVariant>('default');
  const classesCustomizations = useCustomizations<ClassKey>(CLASS_DEFS);

  const text =
    content === 'markdown'
      ? `**Markdown** is rendered automatically:\n\n- bullet one\n- bullet two\n\nInline \`code\` works too.`
      : `Plain text with no formatting—just wraps naturally.`;

  const message = React.useMemo(() => makeMessage(role, 'read', text), [role, text]);

  const contentSx = classesCustomizations.toClassesSx();

  return (
    <PlaygroundCard
      title="ChatMessageContent"
      description="Bubble interior—handles markdown, code fences and tool/source parts."
      previewMinHeight={220}
      span={2}
      classCustomizations={classesCustomizations.customizations}
      onClassesReset={classesCustomizations.reset}
      controls={
        <React.Fragment>
          <DividerLabel>fixture (message data)</DividerLabel>
          <ChoiceControl<Role>
            label="role"
            value={role}
            options={['assistant', 'user'] as const}
            onChange={setRole}
          />
          <SelectControl<'plain' | 'markdown'>
            label="content"
            value={content}
            options={[{ value: 'plain' }, { value: 'markdown' }]}
            onChange={setContent}
          />
          <DividerLabel>chrome provider</DividerLabel>
          <ChoiceControl<ChatVariant>
            label="ChatChrome.variant"
            value={variant}
            options={['default', 'compact'] as const}
            onChange={setVariant}
          />
        </React.Fragment>
      }
      preview={
        <ScopedChat
          conversations={[conversation]}
          messages={[message]}
          activeConversationId={conversation.id}
        >
          <ChatChrome variant={variant} density="standard">
            <Box sx={{ width: '100%', ...contentSx }}>
              <ChatMessageGroup messageId={message.id}>
                <ChatMessageComponent messageId={message.id}>
                  <ChatMessageAvatar />
                  <ChatMessageContent />
                </ChatMessageComponent>
              </ChatMessageGroup>
            </Box>
          </ChatChrome>
        </ScopedChat>
      }
    />
  );
}

Meta

바깥쪽 타임스탬프와 전달 상태 — 컴팩트 버블에서 사용돼요.

import * as React from 'react';
import Box from '@mui/material/Box';
import {
  ChatMessage as ChatMessageComponent,
  ChatMessageAvatar,
  ChatMessageContent,
  ChatMessageGroup,
  ChatMessageMeta,
} from '@mui/x-chat';
import type {
  ChatConversation,
  ChatMessage,
  ChatVariant,
} from '@mui/x-chat/headless';
import { PlaygroundCard } from 'docs/src/modules/components/chat-playground/PlaygroundCard';
import {
  ChatChrome,
  ScopedChat,
} from 'docs/src/modules/components/chat-playground/sharedProviders';
import {
  ChoiceControl,
  DividerLabel,
} from 'docs/src/modules/components/chat-playground/controls';
import {
  useCustomizations,
  type CustomizationDef,
} from 'docs/src/modules/components/chat-playground/useCustomizations';
import { users } from 'docs/src/modules/components/chat-playground/data';

const conversation: ChatConversation = {
  id: 'meta-playground',
  title: 'Parts',
  participants: [users.me, users.assistant],
};

type Role = 'assistant' | 'user';
type Status = 'sent' | 'read' | 'streaming';

function makeMessage(role: Role, status: Status, text: string): ChatMessage {
  const author = role === 'user' ? users.me : users.assistant;
  return {
    id: `meta-${role}-${status}`,
    conversationId: conversation.id,
    role,
    author,
    createdAt: '2026-05-03T09:30:00.000Z',
    status,
    parts: [{ type: 'text', text }],
  };
}

type ClassKey = 'meta';

const CLASS_DEFS: ReadonlyArray<CustomizationDef<ClassKey>> = [
  {
    name: 'meta',
    selector: '.MuiChatMessage-meta',
    description: 'External meta row containing timestamp + status.',
  },
];

export default function ChatMessageMetaPlayground() {
  const [role, setRole] = React.useState<Role>('user');
  const [status, setStatus] = React.useState<Status>('read');
  const [variant, setVariant] = React.useState<ChatVariant>('compact');
  const classesCustomizations = useCustomizations<ClassKey>(CLASS_DEFS);
  const message = React.useMemo(
    () => makeMessage(role, status, 'Meta preview message.'),
    [role, status],
  );

  const metaSx = classesCustomizations.toClassesSx();

  return (
    <PlaygroundCard
      title="ChatMessageMeta"
      description="External meta (timestamp + delivery status) used by compact bubbles."
      previewMinHeight={140}
      classCustomizations={classesCustomizations.customizations}
      onClassesReset={classesCustomizations.reset}
      controls={
        <React.Fragment>
          <DividerLabel>fixture (message data)</DividerLabel>
          <ChoiceControl<Role>
            label="role"
            value={role}
            options={['assistant', 'user'] as const}
            onChange={setRole}
          />
          <ChoiceControl<Status>
            label="status"
            value={status}
            options={['sent', 'read', 'streaming'] as const}
            onChange={setStatus}
          />
          <DividerLabel>chrome provider</DividerLabel>
          <ChoiceControl<ChatVariant>
            label="ChatChrome.variant"
            value={variant}
            options={['default', 'compact'] as const}
            onChange={setVariant}
          />
        </React.Fragment>
      }
      preview={
        <ScopedChat
          conversations={[conversation]}
          messages={[message]}
          activeConversationId={conversation.id}
        >
          <ChatChrome variant={variant} density="standard">
            <Box sx={{ width: '100%', ...metaSx }}>
              <ChatMessageGroup messageId={message.id}>
                <ChatMessageComponent messageId={message.id}>
                  <ChatMessageAvatar />
                  <ChatMessageContent />
                  <ChatMessageMeta />
                </ChatMessageComponent>
              </ChatMessageGroup>
            </Box>
          </ChatChrome>
        </ScopedChat>
      }
    />
  );
}

인라인 메타 (Inline meta)

버블 안에서 흐르는 Telegram 스타일의 타임스탬프와 상태예요.

import * as React from 'react';
import Box from '@mui/material/Box';
import {
  ChatMessage as ChatMessageComponent,
  ChatMessageAvatar,
  ChatMessageContent,
  ChatMessageGroup,
  ChatMessageInlineMeta,
} from '@mui/x-chat';
import type { ChatConversation, ChatMessage } from '@mui/x-chat/headless';
import { PlaygroundCard } from 'docs/src/modules/components/chat-playground/PlaygroundCard';
import {
  ChatChrome,
  ScopedChat,
} from 'docs/src/modules/components/chat-playground/sharedProviders';
import {
  ChoiceControl,
  DividerLabel,
} from 'docs/src/modules/components/chat-playground/controls';
import {
  useCustomizations,
  type CustomizationDef,
} from 'docs/src/modules/components/chat-playground/useCustomizations';
import { users } from 'docs/src/modules/components/chat-playground/data';

const conversation: ChatConversation = {
  id: 'inline-meta-playground',
  title: 'Parts',
  participants: [users.me, users.assistant],
};

type Role = 'assistant' | 'user';
type Status = 'sent' | 'read' | 'streaming';

function makeMessage(role: Role, status: Status, text: string): ChatMessage {
  const author = role === 'user' ? users.me : users.assistant;
  return {
    id: `inline-meta-${role}-${status}`,
    conversationId: conversation.id,
    role,
    author,
    createdAt: '2026-05-03T09:30:00.000Z',
    status,
    parts: [{ type: 'text', text }],
  };
}

type ClassKey = 'inlineMeta' | 'inlineMetaSpacer';

const CLASS_DEFS: ReadonlyArray<CustomizationDef<ClassKey>> = [
  {
    name: 'inlineMeta',
    selector: '.MuiChatMessage-inlineMeta',
    description: 'The container floating at the bottom-right of the bubble.',
  },
  {
    name: 'inlineMetaSpacer',
    selector: '.MuiChatMessage-inlineMetaSpacer',
    description: 'Reserved whitespace so text wraps around the meta block.',
  },
];

export default function ChatMessageInlineMetaPlayground() {
  const [role, setRole] = React.useState<Role>('user');
  const [status, setStatus] = React.useState<Status>('read');
  const classesCustomizations = useCustomizations<ClassKey>(CLASS_DEFS);
  const message = React.useMemo(
    () =>
      makeMessage(
        role,
        status,
        'Inline meta sits at the bottom-right of this bubble.',
      ),
    [role, status],
  );

  const inlineSx = classesCustomizations.toClassesSx();

  return (
    <PlaygroundCard
      title="ChatMessageInlineMeta"
      description="Telegram-style timestamp + status that flows inside the bubble."
      previewMinHeight={200}
      span={2}
      classCustomizations={classesCustomizations.customizations}
      onClassesReset={classesCustomizations.reset}
      controls={
        <React.Fragment>
          <DividerLabel>fixture (message data)</DividerLabel>
          <ChoiceControl<Role>
            label="role"
            value={role}
            options={['assistant', 'user'] as const}
            onChange={setRole}
          />
          <ChoiceControl<Status>
            label="status"
            value={status}
            options={['sent', 'read', 'streaming'] as const}
            onChange={setStatus}
          />
        </React.Fragment>
      }
      preview={
        <ScopedChat
          conversations={[conversation]}
          messages={[message]}
          activeConversationId={conversation.id}
        >
          <ChatChrome variant="default" density="standard">
            <Box sx={{ width: '100%', ...inlineSx }}>
              <ChatMessageGroup messageId={message.id}>
                <ChatMessageComponent messageId={message.id}>
                  <ChatMessageAvatar />
                  <ChatMessageContent afterContent={<ChatMessageInlineMeta />} />
                </ChatMessageComponent>
              </ChatMessageGroup>
            </Box>
          </ChatChrome>
        </ScopedChat>
      }
    />
  );
}

ChatMessageAuthorLabel API

Demos

이 React 컴포넌트의 사용 예시와 자세한 내용은 컴포넌트 데모 페이지를 참고해요:

Import

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

Note: ref는 루트 요소로 전달돼요.

CSS

Rule name

Global class Rule name Description
- actions 메시지 액션 요소에 적용되는 스타일.
- authorLabel 메시지 작성자 라벨 요소에 적용되는 스타일.
- avatar 메시지 아바타 요소에 적용되는 스타일.
- bubble content 안의 메시지 버블 요소에 적용되는 스타일.
- content 메시지 콘텐츠 요소에 적용되는 스타일.
- dateDivider 날짜 구분선 요소에 적용되는 스타일.
- dateDividerLabel 날짜 구분선 안의 서식된 날짜 라벨에 적용되는 스타일.
- dateDividerLine 날짜 구분선 라벨 양쪽의 가로선에 적용되는 스타일.
.Mui-error - 메시지가 error 상태일 때 적용됨
- group 메시지 그룹 요소에 적용되는 스타일.
- groupAuthorName 그룹 작성자 이름 요소에 적용되는 클래스.
- groupTimestamp 그룹 타임스탬프 요소에 적용되는 클래스 (컴팩트 변형만).
- inlineMeta 인라인 meta 컨테이너 요소에 적용되는 스타일 (기본 변형).
- inlineMetaSpacer 인라인 meta 스페이서 요소에 적용되는 스타일 (기본 변형).
- meta 메시지 meta 요소에 적용되는 스타일.
- noAvatar 아바타 슬롯이 숨겨져 있을 때(slots.avatar: null) 그리드가 아바타 트랙을 버리도록 적용됨.
- roleAssistant 메시지 role이 'assistant'일 때 적용됨
- roleUser 메시지 role이 'user'일 때 적용됨
- root 메시지 루트 요소에 적용되는 스타일.
- streaming 메시지가 스트리밍 중일 때 적용됨

Source code

이 페이지에서 원하는 정보를 찾지 못했다면, 더 자세한 내용은 컴포넌트 구현을 살펴보는 것이 좋아요.

ChatMessageAvatar API

Demos

이 React 컴포넌트의 사용 예시와 자세한 내용은 컴포넌트 데모 페이지를 참고해요:

Import

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

Note: ref는 루트 요소로 전달돼요.

Source code

이 페이지에서 원하는 정보를 찾지 못했다면, 더 자세한 내용은 컴포넌트 구현을 살펴보는 것이 좋아요.

ChatMessageContent API

Demos

이 React 컴포넌트의 사용 예시와 자세한 내용은 컴포넌트 데모 페이지를 참고해요:

Import

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

Props

Name Type Default Required Description
afterContent node - No
partProps { dynamic-tool?: { className?: string, defaultExpanded?: object, slotProps?: object, slots?: object, toolSlotProps?: object, toolSlots?: object }, file?: { className?: string, slotProps?: object, slots?: object }, reasoning?: { className?: string, slotProps?: object, slots?: object }, source-document?: { className?: string, slotProps?: object, slots?: object }, source-url?: { className?: string, slotProps?: object, slots?: object }, text?: { renderText?: func }, tool?: { className?: string, defaultExpanded?: object, slotProps?: object, slots?: object, toolSlotProps?: object, toolSlots?: object } } - No

Note: ref는 루트 요소로 전달돼요.

다른 props를 제공하면 루트 요소(네이티브 요소)에 전달돼요.

Source code

이 페이지에서 원하는 정보를 찾지 못했다면, 더 자세한 내용은 컴포넌트 구현을 살펴보는 것이 좋아요.

ChatMessageGroup API

Demos

이 React 컴포넌트의 사용 예시와 자세한 내용은 컴포넌트 데모 페이지를 참고해요:

Import

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

Props

Name Type Default Required Description
groupKey func (message) => message.author?.id ?? message.role ?? '' No

Note: ref는 루트 요소로 전달돼요.

다른 props를 제공하면 루트 요소(네이티브 요소)에 전달돼요.

Source code

이 페이지에서 원하는 정보를 찾지 못했다면, 더 자세한 내용은 컴포넌트 구현을 살펴보는 것이 좋아요.

ChatMessageInlineMeta API

Demos

이 React 컴포넌트의 사용 예시와 자세한 내용은 컴포넌트 데모 페이지를 참고해요:

Import

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

Note: ref는 루트 요소로 전달돼요.

Source code

이 페이지에서 원하는 정보를 찾지 못했다면, 더 자세한 내용은 컴포넌트 구현을 살펴보는 것이 좋아요.

ChatMessageList API

Demos

이 React 컴포넌트의 사용 예시와 자세한 내용은 컴포넌트 데모 페이지를 참고해요:

Import

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

Props

Name Type Default Required Description
autoScroll { buffer?: number } | bool true No
enableRovingFocus bool true No
features { dateDivider?: bool, streamingIndicator?: 'auto' | bool, unreadMarker?: bool } - No
onReachBottom func - No
onReachTop func - No
overlay node null No
renderItem func - No

Note: ref는 루트 요소로 전달돼요.

다른 props를 제공하면 루트 요소(네이티브 요소)에 전달돼요.

CSS

Rule name

Global class Rule name Description
- content 메시지 목록 콘텐츠 요소에 적용되는 스타일.
- root 메시지 목록 루트 요소에 적용되는 스타일.
- scroller 메시지 목록 스크롤러 요소에 적용되는 스타일.

Source code

이 페이지에서 원하는 정보를 찾지 못했다면, 더 자세한 내용은 컴포넌트 구현을 살펴보는 것이 좋아요.

ChatMessageMeta API

Demos

이 React 컴포넌트의 사용 예시와 자세한 내용은 컴포넌트 데모 페이지를 참고해요:

Import

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

Note: ref는 루트 요소로 전달돼요.

Source code

이 페이지에서 원하는 정보를 찾지 못했다면, 더 자세한 내용은 컴포넌트 구현을 살펴보는 것이 좋아요.

더 알아보기 (Learn more)