XDSChatLayout@xds/core · Chat
Preview coming soon

Usage

XDSChatMessageList is the scrollable container for chat messages. It renders children in a flex column with role="log" for accessibility, provides density context to child messages, and supports infinite scroll for loading older messages. Use it inside XDSChatLayout for full-page chat with auto-scroll and composer docking, or standalone for embedded message panels.

Best practices

GuidancePractices
DoCompose messages using MessageList > Message > Bubble for consistent sender-aware styling and density.
DoSet the density prop to control spacing globally — compact for sidebars, balanced for most views, spacious for long-form reading. Individual messages can override.
DoUse the group prop on bubbles (first, middle, last) when a single sender sends multiple consecutive messages — it tightens corner radius to visually connect them.
DoUse XDSChatSystemMessage with variant="divider" for date separators and default for inline status notices like joins, leaves, or topic changes.
DoPut name on the first bubble and metadata on the last bubble in a message so they align with the bubble's inline padding.
DoProvide an emptyState prop so new users see a clear prompt to start a conversation instead of a blank screen.
DoUse the ghost bubble variant for AI-style responses that show rich content like code blocks or markdown without a visible boundary.
Don'tDon't use XDSChatSystemMessage for sender content — it has no avatar, alignment, or bubble. Use XDSChatMessage with a sender role instead.
Don'tDon't put long or multi-line content in a system message — keep it to a single short sentence. If you need more, use a bubble or a card.
Don'tDon't nest XDSChatMessage inside another XDSChatMessage — each message is a standalone article element with its own sender context.
Don'tDon't apply a fixed height directly on the message list — wrap it in a sized container and let the list fill with flex: 1.
Don'tDon't mix filled and ghost bubble variants within the same sender's messages — pick one style per side and use it consistently.
Don'tDon't place metadata or names on both the bubble and the message wrapper — pick one based on whether the content has a bubble boundary.

Anatomy

ElementDescription
Message arearequiredScrollable region for messages. Renders children (typically XDSChatMessageList) in a flex column that pushes content to the bottom when the list is short.
Frosted glass dockrequiredSticky or fixed container at the bottom with a backdrop-blur layer. Houses the scroll button and composer.
Scroll-to-bottom buttonAppears when the user scrolls up or new messages arrive. Defaults to XDSChatLayoutScrollButton; pass null to hide or a custom element to override.
ComposerrequiredThe input area for sending messages, typically XDSChatComposer. Docked at the bottom inside the frosted glass layer.
Empty stateCentered placeholder shown when no messages exist. Use XDSEmptyState for a consistent look.
AvatarA sender avatar rendered beside the message. Typically XDSAvatar with size="small". Hidden for system messages.
NameSender name above the message body. Place on the bubble when using bubbles, or on the message wrapper for raw content.
ContentrequiredThe message body — one or more XDSChatMessageBubble elements, or any free-form ReactNode like images or tool calls.
MetadataTimestamp, delivery status, and footer actions below the message. Place on the last bubble or on the message wrapper.

Import

ts
import {XDSChatLayout} from '@xds/core/Chat'

Props

PropTypeDescription
childrenrequired
ReactNodeMessage content — typically XDSChatMessageList. Flows naturally in the page and scrolls with the container.
composerrequired
ReactNodeComposer element — typically XDSChatComposer. Fixed to the bottom with a frosted glass dock.
emptyState
ReactNodeContent shown when children is empty. Centered vertically in the message area.
scrollButton
ReactNode | nullScroll-to-bottom button rendered above the composer. Defaults to XDSChatLayoutScrollButton with auto-scroll integration. Pass null to hide.
scrollRef
React.RefObject<HTMLElement | null>External scroll container ref. When provided, auto-scroll and scroll-to-bottom target this element instead of the layout root. Use when the chat is embedded in a page where a parent element or the document body scrolls.

Examples

Common configurations, variations, and states.
ChatLayout — Panel ViewNarrow sidebar chat in a constrained container that triggers compact density. Use for side panels, drawers, or embedded chat widgets where horizontal space is limited.
tsx
'use client';
import {
XDSChatLayout,
XDSChatMessageList,
XDSChatMessage,
XDSChatMessageBubble,
XDSChatSystemMessage,
XDSChatComposer,
} from '@xds/core/Chat';
import {XDSMarkdown} from '@xds/core/Markdown';
import * as stylex from '@stylexjs/stylex';
const styles = stylex.create({
panel: {
width: 450,
height: 600,
borderRadius: 8,
overflow: 'hidden',
border: '1px solid var(--color-border)',
},
});
export default function ChatLayoutPanelChat() {
return (
<div {...stylex.props(styles.panel)}>
<XDSChatLayout
composer={
<XDSChatComposer onSubmit={() => {}} placeholder="Ask something..." />
}>
<XDSChatMessageList>
<XDSChatSystemMessage variant="divider">Today</XDSChatSystemMessage>
<XDSChatMessage sender="user">
<XDSChatMessageBubble>
Can you review the Button component and fix the focus ring?
</XDSChatMessageBubble>
</XDSChatMessage>
<XDSChatMessage sender="assistant">
<XDSMarkdown density="compact">{`I'll check the Button component now.
Found the issue — the border radius was hardcoded. Replaced with the theme token.`}</XDSMarkdown>
</XDSChatMessage>
<XDSChatMessage sender="user">
<XDSChatMessageBubble>
Nice, can you also check the Card component?
</XDSChatMessageBubble>
</XDSChatMessage>
<XDSChatMessage sender="assistant">
<XDSMarkdown density="compact">{`Checking the component now.
Found the issue — the border radius was hardcoded. Replaced with the theme token.`}</XDSMarkdown>
</XDSChatMessage>
</XDSChatMessageList>
</XDSChatLayout>
</div>
);
}

Showcase source

tsx
'use client';
import {
XDSChatLayout,
XDSChatMessageList,
XDSChatMessage,
XDSChatMessageBubble,
XDSChatComposer,
XDSChatTokenizedText,
} from '@xds/core/Chat';
import {XDSAvatar} from '@xds/core/Avatar';
import {XDSVStack} from '@xds/core/Stack';
const TOKENS = [{value: '/review', label: '/review', variant: 'blue' as const}];
export default function ChatLayoutShowcase() {
return (
<XDSVStack width={450}>
<XDSChatLayout
composer={
<XDSChatComposer
onSubmit={() => {}}
placeholder="Ask something..."
/>
}>
<XDSChatMessageList>
<XDSChatMessage sender="user">
<XDSChatMessageBubble>
<XDSChatTokenizedText tokens={TOKENS}>
/review the changes in this file
</XDSChatTokenizedText>
</XDSChatMessageBubble>
</XDSChatMessage>
<XDSChatMessage sender="assistant">
<XDSChatMessageBubble variant="ghost">
Reading the file now...
</XDSChatMessageBubble>
</XDSChatMessage>
</XDSChatMessageList>
</XDSChatLayout>
</XDSVStack>
);
}