An open source design system that's fully customizable and agent ready
TypeScript
docs: add consolidated Chat blocks for Composer, Attachments, TokenizedText, ToolCalls, and MessageList (#1717)
Kenton Quatmand9eb38c46103
diff --git a/packages/cli/templates/blocks/components/Chat/ChatComposer.doc.mjs b/packages/cli/templates/blocks/components/Chat/ChatComposer.doc.mjsnew file mode 100644index 0000000000..e21571587c--- /dev/null+++ b/packages/cli/templates/blocks/components/Chat/ChatComposer.doc.mjs@@ -0,0 +1,9 @@+/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */+export const doc = {+ type: 'block',+ name: 'Chat — Composer',+ description: 'Chat composer in default, footer actions, error, and disabled states. Use the default for simple chat, add footer actions for model selectors or settings, and show error status when a message fails to send.',+ isReady: true,+ aspectRatio: 16 / 9,+ componentsUsed: ['Chat', 'Button', 'Layout', 'Text'],+};diff --git a/packages/cli/templates/blocks/components/Chat/ChatComposer.tsx b/packages/cli/templates/blocks/components/Chat/ChatComposer.tsxnew file mode 100644index 0000000000..d6cdde666b--- /dev/null+++ b/packages/cli/templates/blocks/components/Chat/ChatComposer.tsx@@ -0,0 +1,59 @@+'use client';++import {XDSChatComposer} from '@xds/core/Chat';+import {XDSButton} from '@xds/core/Button';+import {XDSStack} from '@xds/core/Layout';+import {XDSText} from '@xds/core/Text';++export default function ChatComposer() {+ return (+ <XDSStack direction="vertical" gap={4}>+ <XDSStack direction="vertical" gap={1}>+ <XDSText type="supporting" color="secondary">+ Default+ </XDSText>+ <XDSChatComposer+ onSubmit={() => {}}+ placeholder="Type a message…"+ />+ </XDSStack>+ <XDSStack direction="vertical" gap={1}>+ <XDSText type="supporting" color="secondary">+ With footer actions+ </XDSText>+ <XDSChatComposer+ onSubmit={() => {}}+ placeholder="Ask me anything…"+ footerActions={+ <>+ <XDSButton label="Auto" variant="ghost" size="md" />+ <XDSButton label="Settings" variant="ghost" size="md" />+ </>+ }+ />+ </XDSStack>+ <XDSStack direction="vertical" gap={1}>+ <XDSText type="supporting" color="secondary">+ Error status+ </XDSText>+ <XDSChatComposer+ onSubmit={() => {}}+ status={{+ type: 'error',+ message: 'Failed to send message. Please try again.',+ }}+ />+ </XDSStack>+ <XDSStack direction="vertical" gap={1}>+ <XDSText type="supporting" color="secondary">+ Disabled+ </XDSText>+ <XDSChatComposer+ onSubmit={() => {}}+ isDisabled+ placeholder="Composer is disabled"+ />+ </XDSStack>+ </XDSStack>+ );+}diff --git a/packages/cli/templates/blocks/components/Chat/ChatComposerAttachments.doc.mjs b/packages/cli/templates/blocks/components/Chat/ChatComposerAttachments.doc.mjsnew file mode 100644index 0000000000..7f0715a9c8--- /dev/null+++ b/packages/cli/templates/blocks/components/Chat/ChatComposerAttachments.doc.mjs@@ -0,0 +1,9 @@+/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */+export const doc = {+ type: 'block',+ name: 'Chat — Composer Attachments',+ description: 'Composer with removable file tokens and a collapsible attachment drawer. Use a context progress bar to show how much of the context window is used, and the collapse toggle when many files are attached.',+ isReady: true,+ aspectRatio: 16 / 9,+ componentsUsed: ['Chat', 'Token', 'ProgressBar', 'Layout', 'Text'],+};diff --git a/packages/cli/templates/blocks/components/Chat/ChatComposerAttachments.tsx b/packages/cli/templates/blocks/components/Chat/ChatComposerAttachments.tsxnew file mode 100644index 0000000000..523886e553--- /dev/null+++ b/packages/cli/templates/blocks/components/Chat/ChatComposerAttachments.tsx@@ -0,0 +1,52 @@+'use client';++import {+ XDSChatComposer,+ XDSChatComposerAttachments,+} from '@xds/core/Chat';+import {XDSToken} from '@xds/core/Token';+import {XDSProgressBar} from '@xds/core/ProgressBar';+import {XDSStack} from '@xds/core/Layout';+import {XDSText} from '@xds/core/Text';++export default function ChatComposerAttachments() {+ return (+ <XDSStack direction="vertical" gap={4}>+ <XDSStack direction="vertical" gap={1}>+ <XDSText type="supporting" color="secondary">+ File attachments with context bar+ </XDSText>+ <XDSChatComposer+ onSubmit={() => {}}+ attachments={+ <XDSChatComposerAttachments>+ <XDSToken label="report.pdf" onRemove={() => {}} />+ <XDSToken label="data.csv" onRemove={() => {}} />+ </XDSChatComposerAttachments>+ }+ headerContext={+ <XDSProgressBar label="Context window" value={3} isLabelHidden />+ }+ />+ </XDSStack>+ <XDSStack direction="vertical" gap={1}>+ <XDSText type="supporting" color="secondary">+ Many attachments with collapse+ </XDSText>+ <XDSChatComposer+ onSubmit={() => {}}+ attachments={+ <XDSChatComposerAttachments count={6}>+ <XDSToken label="new_feature_prd.docx" onRemove={() => {}} />+ <XDSToken label="2026_roadmap.docx" onRemove={() => {}} />+ <XDSToken label="user_flow.pdf" onRemove={() => {}} />+ <XDSToken label="launch_plan.docx" onRemove={() => {}} />+ <XDSToken label="user_feedback.csv" onRemove={() => {}} />+ <XDSToken label="kpis.csv" onRemove={() => {}} />+ </XDSChatComposerAttachments>+ }+ />+ </XDSStack>+ </XDSStack>+ );+}diff --git a/packages/cli/templates/blocks/components/Chat/ChatMessageList.doc.mjs b/packages/cli/templates/blocks/components/Chat/ChatMessageList.doc.mjsnew file mode 100644index 0000000000..437f305cec--- /dev/null+++ b/packages/cli/templates/blocks/components/Chat/ChatMessageList.doc.mjs@@ -0,0 +1,9 @@+/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */+export const doc = {+ type: 'block',+ name: 'Chat — Message List',+ description: 'Full conversation with user bubbles, assistant markdown, avatars, timestamps, delivery status, multi-bubble grouping, and system messages. Shows the core MessageList > Message > Bubble composition pattern.',+ isReady: true,+ aspectRatio: 4 / 3,+ componentsUsed: ['Chat', 'Avatar', 'Markdown', 'Timestamp'],+};diff --git a/packages/cli/templates/blocks/components/Chat/ChatMessageList.tsx b/packages/cli/templates/blocks/components/Chat/ChatMessageList.tsxnew file mode 100644index 0000000000..63237adb87--- /dev/null+++ b/packages/cli/templates/blocks/components/Chat/ChatMessageList.tsx@@ -0,0 +1,81 @@+'use client';++import {+ XDSChatMessageList,+ XDSChatMessage,+ XDSChatMessageBubble,+ XDSChatMessageMetadata,+ XDSChatSystemMessage,+} from '@xds/core/Chat';+import {XDSAvatar} from '@xds/core/Avatar';+import {XDSMarkdown} from '@xds/core/Markdown';+import {XDSTimestamp} from '@xds/core/Timestamp';++export default function ChatMessageList() {+ return (+ <div style={{height: 500, display: 'flex', flexDirection: 'column'}}>+ <XDSChatMessageList>+ <XDSChatSystemMessage variant="divider">Today</XDSChatSystemMessage>++ <XDSChatMessage sender="user">+ <XDSChatMessageBubble+ metadata={+ <XDSChatMessageMetadata+ timestamp={+ <XDSTimestamp value="2026-03-15T14:30:00" format="time" />+ }+ status="read"+ />+ }>+ How should I handle state management in a React app?+ </XDSChatMessageBubble>+ </XDSChatMessage>++ <XDSChatMessage+ sender="assistant"+ avatar={<XDSAvatar name="Navi" size="small" />}>+ <XDSChatMessageBubble+ name={+ <span style={{fontSize: 12, fontWeight: 600, color: '#666'}}>+ Navi+ </span>+ }>+ <XDSMarkdown density="compact">{`For most cases, **React's built-in state** is sufficient:++- \`useState\` for local component state+- \`useReducer\` for complex state logic+- \`useContext\` for shared state across a subtree++Avoid global state managers unless you have a genuine need for cross-cutting state.`}</XDSMarkdown>+ </XDSChatMessageBubble>+ <XDSChatMessageMetadata+ timestamp={+ <XDSTimestamp value="2026-03-15T14:30:30" format="time" />+ }+ footer={<span>Claude Opus 4.6</span>}+ />+ </XDSChatMessage>++ <XDSChatMessage sender="user">+ <XDSChatMessageBubble group="first">+ That makes sense, thanks!+ </XDSChatMessageBubble>+ <XDSChatMessageBubble+ group="last"+ metadata={+ <XDSChatMessageMetadata+ timestamp={+ <XDSTimestamp value="2026-03-15T14:31:00" format="time" />+ }+ status="delivered"+ />+ }>+ What about server state?+ </XDSChatMessageBubble>+ </XDSChatMessage>++ <XDSChatSystemMessage>Navi is thinking…</XDSChatSystemMessage>+ </XDSChatMessageList>+ </div>+ );+}diff --git a/packages/cli/templates/blocks/components/Chat/ChatSimpleConversation.doc.mjs b/packages/cli/templates/blocks/components/Chat/ChatSimpleConversation.doc.mjsdeleted file mode 100644index bd84a3bf09..0000000000--- a/packages/cli/templates/blocks/components/Chat/ChatSimpleConversation.doc.mjs+++ /dev/null@@ -1,10 +0,0 @@-/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */-export const doc = {- type: 'block',- name: 'Chat — Simple Conversation',- description:- 'Basic user/assistant exchange with markdown response, timestamps, and message metadata.',- isReady: true,- aspectRatio: 4 / 3,- componentsUsed: ['Chat', 'Markdown', 'Timestamp'],-};diff --git a/packages/cli/templates/blocks/components/Chat/ChatSimpleConversation.tsx b/packages/cli/templates/blocks/components/Chat/ChatSimpleConversation.tsxdeleted file mode 100644index 6c3b1611eb..0000000000--- a/packages/cli/templates/blocks/components/Chat/ChatSimpleConversation.tsx+++ /dev/null@@ -1,47 +0,0 @@-'use client';--import {- XDSChatMessageList,- XDSChatMessage,- XDSChatMessageBubble,- XDSChatMessageMetadata,-} from '@xds/core/Chat';-import {XDSMarkdown} from '@xds/core/Markdown';-import {XDSTimestamp} from '@xds/core/Timestamp';--export default function ChatSimpleConversation() {- return (- <XDSChatMessageList>- <XDSChatMessage sender="user">- <XDSChatMessageBubble- metadata={- <XDSChatMessageMetadata- timestamp={- <XDSTimestamp value="2026-03-15T14:30:00" format="time" />- }- status="read"- />- }>- How should I handle state management in a React app?- </XDSChatMessageBubble>- </XDSChatMessage>- <XDSChatMessage sender="assistant">- <XDSMarkdown density="compact">{`For most cases, **React's built-in state** is sufficient:--- \`useState\` for local component state-- \`useReducer\` for complex state logic-- \`useContext\` for shared state across a subtree--For **server state**, use a library like **TanStack Query** or **SWR** — they handle caching, revalidation, and loading states out of the box.--Avoid global state managers unless you have a genuine need for cross-cutting state.`}</XDSMarkdown>- <XDSChatMessageMetadata- timestamp={- <XDSTimestamp value="2026-03-15T14:30:30" format="time" />- }- footer={<span>Claude Opus 4.6</span>}- />- </XDSChatMessage>- </XDSChatMessageList>- );-}diff --git a/packages/cli/templates/blocks/components/Chat/ChatTokenizedText.doc.mjs b/packages/cli/templates/blocks/components/Chat/ChatTokenizedText.doc.mjsnew file mode 100644index 0000000000..30db02d4f3--- /dev/null+++ b/packages/cli/templates/blocks/components/Chat/ChatTokenizedText.doc.mjs@@ -0,0 +1,9 @@+/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */+export const doc = {+ type: 'block',+ name: 'Chat — Tokenized Text',+ description: 'Messages with inline token badges for @mentions and hashtags. Single mention, multiple mentions, and mixed color variants side by side. Use inside a bubble to render structured references as styled badges.',+ isReady: true,+ aspectRatio: 16 / 9,+ componentsUsed: ['Chat', 'Layout', 'Text'],+};diff --git a/packages/cli/templates/blocks/components/Chat/ChatTokenizedText.tsx b/packages/cli/templates/blocks/components/Chat/ChatTokenizedText.tsxnew file mode 100644index 0000000000..381763f386--- /dev/null+++ b/packages/cli/templates/blocks/components/Chat/ChatTokenizedText.tsx@@ -0,0 +1,71 @@+'use client';++import {+ XDSChatTokenizedText,+ XDSChatMessage,+ XDSChatMessageBubble,+ XDSChatMessageList,+} from '@xds/core/Chat';+import {XDSStack} from '@xds/core/Layout';+import {XDSText} from '@xds/core/Text';++const mentionTokens = [+ {value: '@cindy', label: '@Cindy Zhang', variant: 'blue' as const},+ {value: '@navi', label: '@Navi', variant: 'blue' as const},+ {value: '@alex', label: '@Alex Rivera', variant: 'blue' as const},+];++const mixedTokens = [+ {value: '@cindy', label: '@Cindy', variant: 'blue' as const},+ {value: '#bug', label: '#bug', variant: 'red' as const},+ {value: '#feat', label: '#feature', variant: 'green' as const},+];++export default function ChatTokenizedText() {+ return (+ <XDSStack direction="vertical" gap={4}>+ <XDSStack direction="vertical" gap={1}>+ <XDSText type="supporting" color="secondary">+ Single mention+ </XDSText>+ <XDSChatMessageList>+ <XDSChatMessage sender="user">+ <XDSChatMessageBubble>+ <XDSChatTokenizedText tokens={mentionTokens}>+ Hey @cindy can you review this?+ </XDSChatTokenizedText>+ </XDSChatMessageBubble>+ </XDSChatMessage>+ </XDSChatMessageList>+ </XDSStack>+ <XDSStack direction="vertical" gap={1}>+ <XDSText type="supporting" color="secondary">+ Multiple mentions+ </XDSText>+ <XDSChatMessageList>+ <XDSChatMessage sender="user">+ <XDSChatMessageBubble>+ <XDSChatTokenizedText tokens={mentionTokens}>+ @cindy and @alex can @navi help with the review?+ </XDSChatTokenizedText>+ </XDSChatMessageBubble>+ </XDSChatMessage>+ </XDSChatMessageList>+ </XDSStack>+ <XDSStack direction="vertical" gap={1}>+ <XDSText type="supporting" color="secondary">+ Mixed variants+ </XDSText>+ <XDSChatMessageList>+ <XDSChatMessage sender="user">+ <XDSChatMessageBubble>+ <XDSChatTokenizedText tokens={mixedTokens}>+ @cindy filed #bug and #feat for the sprint+ </XDSChatTokenizedText>+ </XDSChatMessageBubble>+ </XDSChatMessage>+ </XDSChatMessageList>+ </XDSStack>+ </XDSStack>+ );+}diff --git a/packages/cli/templates/blocks/components/Chat/ChatToolCalls.doc.mjs b/packages/cli/templates/blocks/components/Chat/ChatToolCalls.doc.mjsnew file mode 100644index 0000000000..f2077a0d24--- /dev/null+++ b/packages/cli/templates/blocks/components/Chat/ChatToolCalls.doc.mjs@@ -0,0 +1,9 @@+/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */+export const doc = {+ type: 'block',+ name: 'Chat — Tool Calls',+ description: 'Tool call display in single, multiple, error, and running states. Single calls render inline; multiple calls collapse into a summary. Use for showing LLM function invocations with duration, diff stats, and status.',+ isReady: true,+ aspectRatio: 16 / 9,+ componentsUsed: ['Chat', 'Layout', 'Text'],+};diff --git a/packages/cli/templates/blocks/components/Chat/ChatToolCalls.tsx b/packages/cli/templates/blocks/components/Chat/ChatToolCalls.tsxnew file mode 100644index 0000000000..ecdedb3b5a--- /dev/null+++ b/packages/cli/templates/blocks/components/Chat/ChatToolCalls.tsx@@ -0,0 +1,95 @@+'use client';++import {XDSChatToolCalls} from '@xds/core/Chat';+import {XDSStack} from '@xds/core/Layout';+import {XDSText} from '@xds/core/Text';++export default function ChatToolCalls() {+ return (+ <XDSStack direction="vertical" gap={4}>+ <XDSStack direction="vertical" gap={1}>+ <XDSText type="supporting" color="secondary">+ Single call+ </XDSText>+ <XDSChatToolCalls+ calls={[+ {+ name: 'bash',+ target: 'git status',+ status: 'complete',+ duration: '1.2s',+ },+ ]}+ />+ </XDSStack>+ <XDSStack direction="vertical" gap={1}>+ <XDSText type="supporting" color="secondary">+ Multiple calls with stats+ </XDSText>+ <XDSChatToolCalls+ calls={[+ {+ name: 'bash',+ target: 'git diff --stat',+ status: 'complete',+ duration: '340ms',+ },+ {+ name: 'read',+ target: 'src/Button.tsx',+ status: 'complete',+ duration: '45ms',+ },+ {+ name: 'edit',+ target: 'src/Button.tsx',+ status: 'complete',+ duration: '120ms',+ additions: 12,+ deletions: 3,+ },+ ]}+ />+ </XDSStack>+ <XDSStack direction="vertical" gap={1}>+ <XDSText type="supporting" color="secondary">+ With error+ </XDSText>+ <XDSChatToolCalls+ calls={[+ {+ name: 'bash',+ target: 'yarn build',+ status: 'complete',+ duration: '8s',+ node: 'cli:devvm',+ },+ {+ name: 'bash',+ target: 'yarn test',+ status: 'error',+ duration: '2.1s',+ node: 'cli:devvm',+ errorMessage: 'Process exited with code 1',+ },+ ]}+ />+ </XDSStack>+ <XDSStack direction="vertical" gap={1}>+ <XDSText type="supporting" color="secondary">+ Running+ </XDSText>+ <XDSChatToolCalls+ calls={[+ {+ name: 'bash',+ target: 'yarn test --watch',+ status: 'running',+ node: 'cli:devvm',+ },+ ]}+ />+ </XDSStack>+ </XDSStack>+ );+}diff --git a/packages/core/src/Chat/Chat.doc.mjs b/packages/core/src/Chat/Chat.doc.mjsindex 30420b9486..0fa954b4d8 100644--- a/packages/core/src/Chat/Chat.doc.mjs+++ b/packages/core/src/Chat/Chat.doc.mjs@@ -167,12 +167,14 @@ export const docs = {},],usage: {- description: 'Chat components provide layout primitives and a composer for building AI chat interfaces. Use Chat when building conversational UIs that need message display, sender-aware styling, and rich input with trigger menus and attachments.',+ description: 'Chat builds conversational interfaces — AI assistants, messaging, or any thread-based UI. Compose with MessageList > Message > Bubble for sender-aware styling, density, and accessible markup out of the box.',bestPractices: [{ guidance: true, description: 'Compose messages using MessageList > Message > Bubble for consistent sender-aware styling and density.' },{ guidance: true, description: 'Use the named slots on XDSChatComposer (attachments, headerActions, footerActions) to keep the input layout structured and extensible.' },- { guidance: false, description: 'Place metadata or names on both the bubble and the message wrapper — use one or the other based on whether the content has a bubble boundary.' },- { guidance: false, description: 'Bypass XDSChatLayout for full-page chat — it handles auto-scroll, density adaptation, and composer docking automatically.' },+ { guidance: true, description: 'Put name and metadata on the bubble when the content has a visible bubble boundary. Put them on the message wrapper when the content is raw (no bubble).' },+ { guidance: true, description: 'Use XDSChatLayout for full-page chat — it handles auto-scroll, density adaptation, and composer docking automatically.' },+ { guidance: false, description: 'Place metadata or names on both the bubble and the message wrapper — pick one based on whether the content has a bubble boundary.' },+ { guidance: false, description: 'Build your own scroll management or density breakpoints — XDSChatLayout handles both via container width observation.' },],},};@@ -205,12 +207,14 @@ docs.components.push(chatLayoutScrollButtonComponent);/** @type {import('../docs-types').TranslationDoc} */export const docsZh = {usage: {- description: 'Chat components provide layout primitives and a composer for building AI chat interfaces. Use Chat when building conversational UIs that need message display, sender-aware styling, and rich input with trigger menus and attachments.',+ description: 'Chat builds conversational interfaces — AI assistants, messaging, or any thread-based UI. Compose with MessageList > Message > Bubble for sender-aware styling, density, and accessible markup out of the box.',bestPractices: [{ guidance: true, description: 'Compose messages using MessageList > Message > Bubble for consistent sender-aware styling and density.' },{ guidance: true, description: 'Use the named slots on XDSChatComposer (attachments, headerActions, footerActions) to keep the input layout structured and extensible.' },- { guidance: false, description: 'Place metadata or names on both the bubble and the message wrapper — use one or the other based on whether the content has a bubble boundary.' },- { guidance: false, description: 'Bypass XDSChatLayout for full-page chat — it handles auto-scroll, density adaptation, and composer docking automatically.' },+ { guidance: true, description: 'Put name and metadata on the bubble when the content has a visible bubble boundary. Put them on the message wrapper when the content is raw (no bubble).' },+ { guidance: true, description: 'Use XDSChatLayout for full-page chat — it handles auto-scroll, density adaptation, and composer docking automatically.' },+ { guidance: false, description: 'Place metadata or names on both the bubble and the message wrapper — pick one based on whether the content has a bubble boundary.' },+ { guidance: false, description: 'Build your own scroll management or density breakpoints — XDSChatLayout handles both via container width observation.' },],},components: [@@ -362,12 +366,14 @@ export const docsZh = {export const docsDense = {description: 'AI chat components. Layout (MessageList>Message>Bubble+SystemMessage) + Composer (shell w/ slots, ContentEditable input w/ trigger menus, attachments)',usage: {- description: 'Chat components provide layout primitives and a composer for building AI chat interfaces. Use Chat when building conversational UIs that need message display, sender-aware styling, and rich input with trigger menus and attachments.',+ description: 'Chat builds conversational interfaces — AI assistants, messaging, or any thread-based UI. Compose with MessageList > Message > Bubble for sender-aware styling, density, and accessible markup out of the box.',bestPractices: [{ guidance: true, description: 'Compose messages using MessageList > Message > Bubble for consistent sender-aware styling and density.' },{ guidance: true, description: 'Use the named slots on XDSChatComposer (attachments, headerActions, footerActions) to keep the input layout structured and extensible.' },- { guidance: false, description: 'Place metadata or names on both the bubble and the message wrapper — use one or the other based on whether the content has a bubble boundary.' },- { guidance: false, description: 'Bypass XDSChatLayout for full-page chat — it handles auto-scroll, density adaptation, and composer docking automatically.' },+ { guidance: true, description: 'Put name and metadata on the bubble when the content has a visible bubble boundary. Put them on the message wrapper when the content is raw (no bubble).' },+ { guidance: true, description: 'Use XDSChatLayout for full-page chat — it handles auto-scroll, density adaptation, and composer docking automatically.' },+ { guidance: false, description: 'Place metadata or names on both the bubble and the message wrapper — pick one based on whether the content has a bubble boundary.' },+ { guidance: false, description: 'Build your own scroll management or density breakpoints — XDSChatLayout handles both via container width observation.' },],},components: [