Skip to content
CraftDocs
GitHub
Home
Home
Changelog
What's New
Guide
Guide
Getting Started
Principles
Styling Components
Theme System
Foundations
All Tokens
Color
Elevation
Icons
Motion
Shape
Spacing
Typography
Libraries
Libraries
@xds/cli
@xds/core
Themes
Themes
Theme: daily
Default Theme
Theme: matcha
Neutral Theme
Components
Components
AppShell
AspectRatio
Avatar
Avatar
AvatarStatusDot
Badge
Banner
Breadcrumbs
BreadcrumbItem
Breadcrumbs
Button
Button
IconButton
ToggleButton
ToggleButtonGroup
Calendar
Card
Carousel
Chat
ChatComposer
ChatComposerDrawer
ChatComposerInput
ChatComposerTokenElement
ChatDictationButton
ChatLayout
ChatLayoutScrollButton
ChatMessage
ChatMessageBubble
ChatMessageList
ChatMessageMetadata
ChatSendButton
ChatSystemMessage
ChatTokenizedText
ChatToolCalls
Checkbox
CheckboxInput
CheckboxList
CheckboxListItem
ClickableCard
Code
CodeBlock
Collapsible
Collapsible
CollapsibleGroup
useXDSCollapsible
CommandPalette
CommandPalette
CommandPaletteEmpty
CommandPaletteFooter
CommandPaletteGroup
CommandPaletteInput
CommandPaletteItem
CommandPaletteList
DateInput
Dialog
AlertDialog
Dialog
DialogHeader
useXDSImperativeAlertDialog
useXDSImperativeDialog
Divider
DropdownMenu
DropdownMenu
DropdownMenuDivider
DropdownMenuItem
DropdownMenuItemData
DropdownMenuSection
EmptyState
Field
Field
FieldLabel
FieldStatus
Heading
HoverCard
Icon
Kbd
Layout
Center
FormLayout
Grid
GridSpan
HStack
Layout
LayoutContainer
LayoutContent
LayoutFooter
LayoutHeader
LayoutPanel
Section
StackItem
VStack
Link
List
List
ListItem
Markdown
MetadataList
MetadataList
MetadataListItem
MobileNav
MoreMenu
NavIcon
NavMenuItem
NumberInput
OverflowList
Pagination
Popover
PowerSearch
ProgressBar
Radio
RadioList
RadioListItem
Resizable
ResizeHandle
useXDSResizable
SegmentedControl
SegmentedControl
SegmentedControlItem
SelectableCard
Selector
MultiSelector
Selector
SelectorOption
SideNav
SideNav
SideNavCollapseButton
SideNavHeading
SideNavItem
SideNavSection
Skeleton
Slider
Spinner
StatusDot
Switch
Table
BaseTable
Table
TableCell
TableHeaderCell
TableRow
useXDSTableColumnSettings
useXDSTablePagination
useXDSTableSelection
useXDSTableSelectionState
useXDSTableSortable
Tabs
Tab
TabList
TabMenu
Text
TextArea
TextInput
Thumbnail
TimeInput
Timestamp
Toast
Toast
useXDSToast
Token
Tokenizer
Toolbar
Tooltip
TopNav
TopNav
TopNavHeading
TopNavItem
TopNavMegaMenu
TopNavMegaMenuFeaturedCard
TopNavMegaMenuItem
TopNavMenu
TreeList
Typeahead
BaseTypeahead
Typeahead
TypeaheadItem
useXDSHoverCard
useXDSPopover
useXDSTooltip
Utilities
Utilities
LinkProvider
MediaTheme
SyntaxTheme
Theme
useClickableContainer
useEntryAnimation
useFocusTrap
useGridFocus
useImageMode
useInputContainer
useListFocus
useMediaQuery
useOverflow
useScrollLock
useScrollOverflow
useXDSLayer
useXDSStreamingText
Terms of UsePrivacy Policy
Type to search
↑↓Navigate↵SelectEscClose
ChatMessageBubble@xds/core · XDSChatMessageBubble v0.0.13

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.
ts
import {XDSChatMessageBubble} from '@xds/core/Chat'

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.

Examples

Common configurations, variations, and states.
ChatMessageBubble — DensityCompact, balanced, and spacious density modes side by side. Density controls bubble padding, corner radius, and spacing between grouped bubbles.
tsx
'use client';
​
import {
XDSChatMessageList,
XDSChatMessage,
XDSChatMessageBubble,
} from '@xds/core/Chat';
import {XDSText} from '@xds/core/Text';
import {XDSVStack} from '@xds/core/Layout';
​
const DENSITIES = [
{density: 'compact' as const, label: 'Compact'},
{density: 'balanced' as const, label: 'Balanced'},
{density: 'spacious' as const, label: 'Spacious'},
];
​
export default function ChatMessageBubbleDensity() {
return (
<XDSVStack gap={5}>
{DENSITIES.map(({density, label}) => (
<XDSVStack key={density} gap={1}>
<XDSText type="supporting" color="secondary">
{label}
</XDSText>
<XDSChatMessageList density={density}>
<XDSChatMessage sender="assistant">
<XDSChatMessageBubble>
The build completed in 4.2 seconds.
</XDSChatMessageBubble>
</XDSChatMessage>
<XDSChatMessage sender="user">
<XDSChatMessageBubble>
Ship it to staging.
</XDSChatMessageBubble>
</XDSChatMessage>
</XDSChatMessageList>
</XDSVStack>
))}
</XDSVStack>
);
}
ChatMessageBubble — GroupingMulti-bubble messages using first, middle, and last group positions. Grouped bubbles tighten corner radius on the sender side for a continuous visual flow.
tsx
'use client';
​
import {
XDSChatMessageList,
XDSChatMessage,
XDSChatMessageBubble,
XDSChatMessageMetadata,
} from '@xds/core/Chat';
import {XDSAvatar} from '@xds/core/Avatar';
import {XDSTimestamp} from '@xds/core/Timestamp';
import {XDSText} from '@xds/core/Text';
import {XDSVStack} from '@xds/core/Layout';
​
export default function ChatMessageBubbleGrouping() {
return (
<XDSVStack gap={4}>
<XDSText type="supporting" color="secondary">
Grouped bubbles with tightened sender-side corners
</XDSText>
<XDSChatMessageList>
<XDSChatMessage
sender="assistant"
avatar={<XDSAvatar name="Agent" size="small" />}>
<XDSChatMessageBubble
group="first"
name={
<XDSText type="supporting" weight="semibold" color="secondary">
Agent
</XDSText>
}>
I reviewed the three files you shared.
</XDSChatMessageBubble>
<XDSChatMessageBubble group="middle">
The data model looks solid, but the API handler has a race
condition on concurrent writes.
</XDSChatMessageBubble>
<XDSChatMessageBubble
group="last"
metadata={
<XDSChatMessageMetadata
timestamp={
<XDSTimestamp value="2026-04-10T10:45:00" format="time" />
}
/>
}>
I can draft a fix if you want.
</XDSChatMessageBubble>
</XDSChatMessage>
​
<XDSChatMessage sender="user">
<XDSChatMessageBubble group="first">
Yes please!
</XDSChatMessageBubble>
<XDSChatMessageBubble
group="last"
metadata={
<XDSChatMessageMetadata
timestamp={
<XDSTimestamp value="2026-04-10T10:46:00" format="time" />
}
status="delivered"
/>
}>
Also add a test for the concurrent case.
</XDSChatMessageBubble>
</XDSChatMessage>
</XDSChatMessageList>
</XDSVStack>
);
}
ChatMessageBubble — MetadataBubbles with name and metadata slots aligned to bubble padding. Put name on the first bubble and metadata on the last bubble in a message.
tsx
'use client';
​
import {
XDSChatMessageList,
XDSChatMessage,
XDSChatMessageBubble,
XDSChatMessageMetadata,
} from '@xds/core/Chat';
import {XDSAvatar} from '@xds/core/Avatar';
import {XDSTimestamp} from '@xds/core/Timestamp';
import {XDSText} from '@xds/core/Text';
import {XDSButton} from '@xds/core/Button';
import {XDSIcon} from '@xds/core/Icon';
import {XDSHStack, XDSVStack} from '@xds/core/Layout';
​
export default function ChatMessageBubbleMetadata() {
return (
<XDSVStack gap={4}>
<XDSText type="supporting" color="secondary">
Name on first bubble, metadata on last
</XDSText>
<XDSChatMessageList>
<XDSChatMessage
sender="assistant"
avatar={<XDSAvatar name="Agent" size="small" />}>
<XDSChatMessageBubble
name={
<XDSText type="supporting" weight="semibold" color="secondary">
Agent
</XDSText>
}
metadata={
<XDSChatMessageMetadata
timestamp={
<XDSTimestamp value="2026-04-10T09:15:00" format="time" />
}
footer={
<XDSHStack gap={1}>
<XDSButton
label="Copy"
variant="ghost"
size="sm"
icon={<XDSIcon icon="copy" size="sm" />}
isIconOnly
onClick={() => {}}
/>
<XDSText type="supporting" color="secondary">
Claude Opus 4.6
</XDSText>
</XDSHStack>
}
/>
}>
Your deployment finished successfully. All 14 checks passed.
</XDSChatMessageBubble>
</XDSChatMessage>
​
<XDSChatMessage sender="user">
<XDSChatMessageBubble
metadata={
<XDSChatMessageMetadata
timestamp={
<XDSTimestamp value="2026-04-10T09:16:00" format="time" />
}
status="read"
/>
}>
Great, can you send me the production URL?
</XDSChatMessageBubble>
</XDSChatMessage>
</XDSChatMessageList>
</XDSVStack>
);
}
ChatMessageBubble — VariantsFilled and ghost bubble variants for both user and assistant senders. Use filled for standard messages and ghost when content needs alignment without a visual boundary.
tsx
'use client';
​
import {
XDSChatMessageList,
XDSChatMessage,
XDSChatMessageBubble,
} from '@xds/core/Chat';
import {XDSStack} from '@xds/core/Layout';
import {XDSText} from '@xds/core/Text';
​
export default function ChatMessageBubbleVariants() {
return (
<XDSStack direction="vertical" gap={4}>
<XDSStack direction="vertical" gap={1}>
<XDSText type="supporting" color="secondary">
Filled — sender-colored background (default)
</XDSText>
<XDSChatMessageList>
<XDSChatMessage sender="user">
<XDSChatMessageBubble>
Can you summarize the latest deployment logs?
</XDSChatMessageBubble>
</XDSChatMessage>
</XDSChatMessageList>
</XDSStack>
<XDSStack direction="vertical" gap={1}>
<XDSText type="supporting" color="secondary">
Ghost — transparent background, keeps alignment padding
</XDSText>
<XDSChatMessageList>
<XDSChatMessage sender="assistant">
<XDSChatMessageBubble variant="ghost">
The last deploy completed at 2:41 PM with zero errors across all
three regions.
</XDSChatMessageBubble>
</XDSChatMessage>
</XDSChatMessageList>
</XDSStack>
</XDSStack>
);
}

Showcase source

tsx
'use client';
​
import {
XDSChatMessageList,
XDSChatMessage,
XDSChatMessageBubble,
XDSChatMessageMetadata,
} from '@xds/core/Chat';
import {XDSTimestamp} from '@xds/core/Timestamp';
import * as stylex from '@stylexjs/stylex';
​
const styles = stylex.create({
root: {
maxWidth: 600,
},
});
​
export default function ChatMessageBubbleShowcase() {
return (
<div {...stylex.props(styles.root)}>
<XDSChatMessageList>
<XDSChatMessage sender="user">
<XDSChatMessageBubble group="first">
I just pushed the latest changes to the feature branch.
</XDSChatMessageBubble>
<XDSChatMessageBubble
group="last"
metadata={
<XDSChatMessageMetadata
timestamp={
<XDSTimestamp value="2026-04-10T09:15:00" format="time" />
}
status="read"
/>
}>
Can you review when you get a chance?
</XDSChatMessageBubble>
</XDSChatMessage>
​
<XDSChatMessage sender="assistant">
<XDSChatMessageBubble
variant="ghost"
metadata={
<XDSChatMessageMetadata
timestamp={
<XDSTimestamp value="2026-04-10T09:16:00" format="time" />
}
/>
}>
The changes look great — clean code, good test coverage. Ship it!
</XDSChatMessageBubble>
</XDSChatMessage>
</XDSChatMessageList>
</div>
);
}