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
ChatComposerInput@xds/core · XDSChatComposerInput 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 {XDSChatComposerInput} 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.
ChatComposerInput — ControlledControlled chat input with live value display. Use controlled mode when you need to read or transform the input value outside the composer.
tsx
'use client';
​
import {useState} from 'react';
import {XDSChatComposer, XDSChatComposerInput} from '@xds/core/Chat';
import {XDSStack} from '@xds/core/Layout';
import {XDSText} from '@xds/core/Text';
​
export default function ChatComposerInputControlledInput() {
const [value, setValue] = useState('');
return (
<XDSStack direction="vertical" gap={3} style={{width: '100%', maxWidth: 450}}>
<XDSChatComposer
onSubmit={() => setValue('')}
value={value}
onChange={setValue}
input={
<XDSChatComposerInput
value={value}
onChange={setValue}
placeholder="Type a message..."
/>
}
/>
<XDSText type="supporting" color="secondary">
Value: {JSON.stringify(value)}
</XDSText>
</XDSStack>
);
}
ChatComposerInput — DisabledComposer in a disabled state. Use when the input should be visible but not interactive, such as during streaming or when a prerequisite is unmet.
tsx
'use client';
​
import {XDSChatComposer, XDSChatComposerInput} from '@xds/core/Chat';
import {XDSStack} from '@xds/core/Layout';
​
export default function ChatComposerInputDisabled() {
return (
<XDSStack direction="vertical" style={{width: '100%', maxWidth: 450}}>
<XDSChatComposer
onSubmit={() => {}}
isDisabled
input={
<XDSChatComposerInput isDisabled placeholder="Input is disabled" />
}
/>
</XDSStack>
);
}
ChatComposerInput — MentionsChat input with an @ trigger that opens a typeahead menu for mentioning users. Selected names appear as inline tokens.
tsx
'use client';
​
import {useState} from 'react';
import {
XDSChatComposer,
XDSChatComposerInput,
type XDSChatComposerTrigger,
} from '@xds/core/Chat';
import {createStaticSource} from '@xds/core/Typeahead';
import {XDSTypeaheadItem} from '@xds/core/Typeahead';
import type {XDSSearchableItem} from '@xds/core/Typeahead';
import {XDSStack} from '@xds/core/Layout';
import {XDSText} from '@xds/core/Text';
​
const USERS: XDSSearchableItem<{role: string}>[] = [
{id: 'cindy', label: 'Cindy Zhang', auxiliaryData: {role: 'Design Systems'}},
{id: 'alex', label: 'Alex Johnson', auxiliaryData: {role: 'Frontend'}},
{id: 'sam', label: 'Sam Rivera', auxiliaryData: {role: 'Backend'}},
{id: 'jordan', label: 'Jordan Lee', auxiliaryData: {role: 'Product'}},
];
​
const userSource = createStaticSource(USERS);
​
export default function ChatComposerInputMentionTrigger() {
const [value, setValue] = useState('');
​
const mentionTrigger: XDSChatComposerTrigger = {
character: '@',
searchSource: userSource,
renderItem: item => (
<XDSTypeaheadItem
item={item}
description={(item.auxiliaryData as {role: string})?.role}
/>
),
onSelect: item => ({
value: `@${item.id}`,
label: item.label,
variant: 'blue' as const,
}),
};
​
return (
<XDSStack direction="vertical" gap={3} style={{width: '100%', maxWidth: 450}}>
<XDSChatComposer
onSubmit={() => setValue('')}
input={
<XDSChatComposerInput
value={value}
onChange={setValue}
triggers={[mentionTrigger]}
placeholder="Type @ to mention someone..."
/>
}
/>
<XDSText type="supporting" color="secondary">
Value: {JSON.stringify(value)}
</XDSText>
</XDSStack>
);
}
ChatComposerInput — Multiple TriggersChat input with both @ mentions and / commands. Each trigger type renders tokens in a distinct color so users can tell them apart at a glance.
tsx
'use client';
​
import {useState} from 'react';
import {
XDSChatComposer,
XDSChatComposerInput,
type XDSChatComposerTrigger,
} from '@xds/core/Chat';
import {createStaticSource} from '@xds/core/Typeahead';
import type {XDSSearchableItem} from '@xds/core/Typeahead';
import {XDSStack} from '@xds/core/Layout';
import {XDSText} from '@xds/core/Text';
​
const USERS: XDSSearchableItem[] = [
{id: 'cindy', label: 'Cindy Zhang'},
{id: 'alex', label: 'Alex Johnson'},
{id: 'sam', label: 'Sam Rivera'},
{id: 'jordan', label: 'Jordan Lee'},
];
​
const COMMANDS: XDSSearchableItem[] = [
{id: 'summarize', label: 'summarize'},
{id: 'translate', label: 'translate'},
{id: 'search', label: 'search'},
{id: 'code', label: 'code'},
];
​
const userSource = createStaticSource(USERS);
const commandSource = createStaticSource(COMMANDS);
​
export default function ChatComposerInputMultipleTriggers() {
const [value, setValue] = useState('');
​
const mentionTrigger: XDSChatComposerTrigger = {
character: '@',
searchSource: userSource,
onSelect: item => ({
value: `@${item.id}`,
label: item.label,
variant: 'blue' as const,
}),
};
​
const commandTrigger: XDSChatComposerTrigger = {
character: '/',
searchSource: commandSource,
onSelect: item => ({
value: `/${item.label}`,
label: `/${item.label}`,
variant: 'yellow' as const,
}),
};
​
return (
<XDSStack direction="vertical" gap={3} style={{width: '100%', maxWidth: 450}}>
<XDSText type="supporting" color="secondary">
Type @ for mentions (blue) or / for commands (yellow)
</XDSText>
<XDSChatComposer
onSubmit={() => setValue('')}
input={
<XDSChatComposerInput
value={value}
onChange={setValue}
triggers={[mentionTrigger, commandTrigger]}
placeholder="Type @ or / ..."
/>
}
/>
<XDSText type="supporting" color="secondary">
Value: {JSON.stringify(value)}
</XDSText>
</XDSStack>
);
}
ChatComposerInput — Slash CommandsChat input with a / trigger for command selection. Use for AI assistants or bots that support structured commands.
tsx
'use client';
​
import {
XDSChatComposer,
XDSChatComposerInput,
type XDSChatComposerTrigger,
} from '@xds/core/Chat';
import {createStaticSource} from '@xds/core/Typeahead';
import {XDSTypeaheadItem} from '@xds/core/Typeahead';
import type {XDSSearchableItem} from '@xds/core/Typeahead';
import {XDSStack} from '@xds/core/Layout';
​
const COMMANDS: XDSSearchableItem<{description: string}>[] = [
{id: 'summarize', label: 'summarize', auxiliaryData: {description: 'Summarize the conversation'}},
{id: 'translate', label: 'translate', auxiliaryData: {description: 'Translate text to another language'}},
{id: 'search', label: 'search', auxiliaryData: {description: 'Search the web or documents'}},
{id: 'code', label: 'code', auxiliaryData: {description: 'Generate or explain code'}},
{id: 'help', label: 'help', auxiliaryData: {description: 'Show available commands'}},
];
​
const commandSource = createStaticSource(COMMANDS);
​
export default function ChatComposerInputSlashCommands() {
const commandTrigger: XDSChatComposerTrigger = {
character: '/',
searchSource: commandSource,
renderItem: item => (
<XDSTypeaheadItem
item={item}
description={(item.auxiliaryData as {description: string})?.description}
/>
),
onSelect: item => ({
value: `/${item.label}`,
label: `/${item.label}`,
variant: 'yellow' as const,
}),
};
​
return (
<XDSStack direction="vertical" style={{width: '100%', maxWidth: 450}}>
<XDSChatComposer
onSubmit={() => {}}
input={
<XDSChatComposerInput
triggers={[commandTrigger]}
placeholder="Type / for commands..."
/>
}
/>
</XDSStack>
);
}

Showcase source

tsx
'use client';
​
import {XDSChatComposer, XDSChatComposerInput} from '@xds/core/Chat';
import {XDSStack} from '@xds/core/Layout';
​
export default function ChatComposerInputShowcase() {
return (
<XDSStack direction="vertical" style={{width: '100%', maxWidth: 450}}>
<XDSChatComposer
onSubmit={() => {}}
input={
<XDSChatComposerInput placeholder="Ask me anything about XDS..." />
}
/>
</XDSStack>
);
}