An open source design system that's fully customizable and agent ready
TypeScript
Improve ChatComposer docs page and block examples (#1854)
Kenton Quatman8a7f9b464736
diff --git a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerAttachments.doc.mjs b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerAttachments.doc.mjsnew file mode 100644index 0000000000..5a1ce7440b--- /dev/null+++ b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerAttachments.doc.mjs@@ -0,0 +1,9 @@+/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */+export const doc = {+ type: 'block',+ name: 'ChatComposer — Attachments',+ description: 'Chat composer with removable file tokens in a collapsible drawer. Use when users can attach files or context to their message.',+ isReady: true,+ aspectRatio: 16 / 9,+ componentsUsed: ['ChatComposer', 'Token', 'Layout'],+};diff --git a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerAttachments.tsx b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerAttachments.tsxnew file mode 100644index 0000000000..9036ed7954--- /dev/null+++ b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerAttachments.tsx@@ -0,0 +1,27 @@+'use client';++import {XDSChatComposer, XDSChatComposerDrawer} from '@xds/core/Chat';+import {XDSToken} from '@xds/core/Token';+import {XDSStack} from '@xds/core/Layout';++export default function ChatComposerAttachments() {+ return (+ <XDSStack direction="vertical" style={{width: '100%', maxWidth: 450}}>+ <XDSChatComposer+ onSubmit={value => {+ console.log('Sent:', value);+ }}+ drawer={+ <XDSChatComposerDrawer count={6}>+ <XDSToken label="feature-prd.docx" onRemove={() => {}} />+ <XDSToken label="2026-roadmap.pdf" onRemove={() => {}} />+ <XDSToken label="user-flow.fig" onRemove={() => {}} />+ <XDSToken label="launch-plan.docx" onRemove={() => {}} />+ <XDSToken label="user-feedback.csv" onRemove={() => {}} />+ <XDSToken label="analytics-kpis.csv" onRemove={() => {}} />+ </XDSChatComposerDrawer>+ }+ />+ </XDSStack>+ );+}diff --git a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerComposerWithDrawer.doc.mjs b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerComposerWithDrawer.doc.mjsdeleted file mode 100644index 93e211fffd..0000000000--- a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerComposerWithDrawer.doc.mjs+++ /dev/null@@ -1,10 +0,0 @@-/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */-export const doc = {- type: 'block',- name: 'ChatComposer — With Drawer',- description:- 'Chat composer with removable file tokens in a drawer and a context progress bar.',- isReady: true,- aspectRatio: 4 / 3,- componentsUsed: ['ChatComposer', 'Token', 'ProgressBar'],-};diff --git a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerComposerWithDrawer.tsx b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerComposerWithDrawer.tsxdeleted file mode 100644index 2e4732c978..0000000000--- a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerComposerWithDrawer.tsx+++ /dev/null@@ -1,22 +0,0 @@-'use client';--import {XDSChatComposer, XDSChatComposerDrawer} from '@xds/core/Chat';-import {XDSToken} from '@xds/core/Token';-import {XDSProgressBar} from '@xds/core/ProgressBar';--export default function ChatComposerComposerWithDrawer() {- return (- <XDSChatComposer- onSubmit={() => {}}- drawer={- <XDSChatComposerDrawer>- <XDSToken label="report.pdf" onRemove={() => {}} />- <XDSToken label="data.csv" onRemove={() => {}} />- </XDSChatComposerDrawer>- }- headerContext={- <XDSProgressBar label="Context window" value={3} isLabelHidden />- }- />- );-}diff --git a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerComposerWithError.doc.mjs b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerComposerWithError.doc.mjsdeleted file mode 100644index ad7bed7b17..0000000000--- a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerComposerWithError.doc.mjs+++ /dev/null@@ -1,10 +0,0 @@-/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */-export const doc = {- type: 'block',- name: 'ChatComposer — Error Status',- description:- 'Chat composer displaying an error status message below the input.',- isReady: true,- aspectRatio: 4 / 3,- componentsUsed: ['ChatComposer'],-};diff --git a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerComposerWithError.tsx b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerComposerWithError.tsxdeleted file mode 100644index be835ea202..0000000000--- a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerComposerWithError.tsx+++ /dev/null@@ -1,15 +0,0 @@-'use client';--import {XDSChatComposer} from '@xds/core/Chat';--export default function ChatComposerComposerWithError() {- return (- <XDSChatComposer- onSubmit={() => {}}- status={{- type: 'error',- message: 'Failed to send message. Please try again.',- }}- />- );-}diff --git a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerFollowUpQuestions.doc.mjs b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerFollowUpQuestions.doc.mjsdeleted file mode 100644index 76432c032d..0000000000--- a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerFollowUpQuestions.doc.mjs+++ /dev/null@@ -1,10 +0,0 @@-/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */-export const doc = {- type: 'block',- name: 'ChatComposer — Follow-Up Questions',- description:- 'Chat composer with a collapsible drawer containing navigable follow-up questions and selectable lettered options.',- isReady: true,- aspectRatio: 4 / 3,- componentsUsed: ['ChatComposer', 'List', 'Badge', 'Text', 'Button'],-};diff --git a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerFollowUpQuestions.tsx b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerFollowUpQuestions.tsxdeleted file mode 100644index 159019113e..0000000000--- a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerFollowUpQuestions.tsx+++ /dev/null@@ -1,142 +0,0 @@-'use client';--import {useState} from 'react';-import {XDSChatComposer, XDSChatComposerDrawer} from '@xds/core/Chat';-import {XDSButton} from '@xds/core/Button';-import {XDSList, XDSListItem} from '@xds/core/List';-import {XDSText} from '@xds/core/Text';-import {XDSBadge} from '@xds/core/Badge';--const ChevronLeftIcon = (- <svg- width="1em"- height="1em"- viewBox="0 0 24 24"- fill="none"- stroke="currentColor"- strokeWidth="1.5"- strokeLinecap="round"- strokeLinejoin="round">- <path d="m15 18-6-6 6-6" />- </svg>-);-const ChevronRightIcon = (- <svg- width="1em"- height="1em"- viewBox="0 0 24 24"- fill="none"- stroke="currentColor"- strokeWidth="1.5"- strokeLinecap="round"- strokeLinejoin="round">- <path d="m9 18 6-6-6-6" />- </svg>-);--const questions = [- {- question: 'Which environment should this deploy to?',- options: [- {key: 'A', label: 'Production (requires approval)'},- {key: 'B', label: 'Staging'},- {key: 'C', label: 'Local development only'},- ],- },- {- question:- 'This will modify 12 files. How should I handle breaking changes?',- options: [- {key: 'A', label: 'Add a migration and keep backward compatibility'},- {- key: 'B',- label: 'Breaking change is fine \u2014 bump the major version',- },- ],- },- {- question: 'I found 3 existing implementations. Which one should I extend?',- options: [- {key: 'A', label: 'UserService in src/services/ (most recent)'},- {key: 'B', label: 'UserManager in src/legacy/ (has more test coverage)'},- {key: 'C', label: 'Neither \u2014 start fresh'},- ],- },-];--export default function ChatComposerFollowUpQuestions() {- const [currentQ, setCurrentQ] = useState(0);- const [answers, setAnswers] = useState<Record<number, string>>({});- const q = questions[currentQ];- const selected = answers[currentQ] ?? null;-- return (- <XDSChatComposer- onSubmit={value => {- console.log('Submit:', value, '| Answers:', answers);- }}- placeholder="Or describe what you need in your own words\u2026"- drawer={- <XDSChatComposerDrawer count={questions.length} label="Questions">- <div style={{width: '100%'}}>- <div- style={{- display: 'flex',- alignItems: 'center',- justifyContent: 'space-between',- marginBlockEnd: 4,- }}>- <XDSButton- label="Previous question"- variant="ghost"- size="sm"- icon={ChevronLeftIcon}- isIconOnly- isDisabled={currentQ === 0}- onClick={() => setCurrentQ(i => i - 1)}- />- <XDSText color="secondary">- {currentQ + 1} of {questions.length}- </XDSText>- <XDSButton- label="Next question"- variant="ghost"- size="sm"- icon={ChevronRightIcon}- isIconOnly- isDisabled={currentQ === questions.length - 1}- onClick={() => setCurrentQ(i => i + 1)}- />- </div>- <XDSList>- <XDSListItem- label={- <XDSText weight="bold">- {currentQ + 1}. {q.question}- </XDSText>- }- />- {q.options.map(opt => (- <XDSListItem- key={opt.key}- label={opt.label}- startContent={- <XDSBadge- variant={selected === opt.key ? 'info' : 'neutral'}- label={opt.key}- />- }- isSelected={selected === opt.key}- onClick={() =>- setAnswers(prev => ({...prev, [currentQ]: opt.key}))- }- />- ))}- </XDSList>- </div>- </XDSChatComposerDrawer>- }- footerActions={<XDSButton label="Skip all" variant="ghost" size="md" />}- />- );-}diff --git a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerFooterActions.doc.mjs b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerFooterActions.doc.mjsnew file mode 100644index 0000000000..73862bed5a--- /dev/null+++ b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerFooterActions.doc.mjs@@ -0,0 +1,9 @@+/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */+export const doc = {+ type: 'block',+ name: 'ChatComposer — Footer Actions',+ description: 'Chat composer with dropdown menus for a model selector and settings in the footer, and a mic button in the send actions slot.',+ isReady: true,+ aspectRatio: 16 / 9,+ componentsUsed: ['ChatComposer', 'Button', 'DropdownMenu', 'Icon', 'Layout', 'Text'],+};diff --git a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerFooterActions.tsx b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerFooterActions.tsxnew file mode 100644index 0000000000..ce726099cf--- /dev/null+++ b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerFooterActions.tsx@@ -0,0 +1,74 @@+'use client';++import {XDSChatComposer} from '@xds/core/Chat';+import {XDSButton} from '@xds/core/Button';+import {XDSDropdownMenu} from '@xds/core/DropdownMenu';+import {XDSIcon} from '@xds/core/Icon';+import {XDSStack} from '@xds/core/Layout';+import {XDSText} from '@xds/core/Text';+import {+ Cog6ToothIcon,+ MicrophoneIcon,+ SparklesIcon,+} from '@heroicons/react/24/outline';++export default function ChatComposerFooterActions() {+ return (+ <XDSStack direction="vertical" gap={4} style={{width: '100%', maxWidth: 450}}>+ <XDSStack direction="vertical" gap={1}>+ <XDSText type="supporting" color="secondary">+ Model selector and settings dropdowns+ </XDSText>+ <XDSChatComposer+ onSubmit={value => {+ console.log('Sent:', value);+ }}+ footerActions={+ <>+ <XDSDropdownMenu+ button={{+ label: 'Auto',+ variant: 'ghost',+ size: 'md',+ icon: <XDSIcon icon={SparklesIcon} size="sm" />,+ children: 'Auto',+ }}+ menuWidth={200}+ items={[+ {label: 'Auto', onClick: () => {}},+ {label: 'Model A', onClick: () => {}},+ {label: 'Model B', onClick: () => {}},+ {label: 'Model C', onClick: () => {}},+ ]}+ />+ <XDSDropdownMenu+ button={{+ label: 'Settings',+ variant: 'ghost',+ size: 'md',+ icon: <XDSIcon icon={Cog6ToothIcon} size="sm" />,+ children: 'Settings',+ }}+ menuWidth={200}+ items={[+ {label: 'Preferences', onClick: () => {}},+ {label: 'Keyboard shortcuts', onClick: () => {}},+ {label: 'About', onClick: () => {}},+ ]}+ />+ </>+ }+ sendActions={+ <XDSButton+ label="Microphone"+ variant="ghost"+ size="md"+ icon={<XDSIcon icon={MicrophoneIcon} />}+ isIconOnly+ />+ }+ />+ </XDSStack>+ </XDSStack>+ );+}diff --git a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerFullFeatured.doc.mjs b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerFullFeatured.doc.mjsnew file mode 100644index 0000000000..06031b6171--- /dev/null+++ b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerFullFeatured.doc.mjs@@ -0,0 +1,9 @@+/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */+export const doc = {+ type: 'block',+ name: 'ChatComposer — Full Featured',+ description: 'Chat composer with all slots populated — collapsible attachment drawer, header actions, context progress bar, footer dropdown menus, and mic button. Shows the maximum composer configuration.',+ isReady: true,+ aspectRatio: 4 / 3,+ componentsUsed: ['ChatComposer', 'Token', 'Button', 'DropdownMenu', 'Icon', 'ProgressBar', 'Layout', 'Text'],+};diff --git a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerFullFeatured.tsx b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerFullFeatured.tsxnew file mode 100644index 0000000000..78d025e224--- /dev/null+++ b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerFullFeatured.tsx@@ -0,0 +1,114 @@+'use client';++import {useState} from 'react';+import {XDSChatComposer, XDSChatComposerDrawer} from '@xds/core/Chat';+import {XDSToken} from '@xds/core/Token';+import {XDSButton} from '@xds/core/Button';+import {XDSDropdownMenu} from '@xds/core/DropdownMenu';+import {XDSIcon} from '@xds/core/Icon';+import {XDSProgressBar} from '@xds/core/ProgressBar';+import {XDSStack} from '@xds/core/Layout';+import {XDSText} from '@xds/core/Text';+import {+ AtSymbolIcon,+ Cog6ToothIcon,+ MicrophoneIcon,+ PaperClipIcon,+ SparklesIcon,+} from '@heroicons/react/24/outline';++export default function ChatComposerFullFeatured() {+ const [isStreaming, setIsStreaming] = useState(false);++ return (+ <XDSStack direction="vertical" gap={4} style={{width: '100%', maxWidth: 450}}>+ <XDSText type="supporting" color="secondary">+ All slots populated+ </XDSText>+ <XDSChatComposer+ onSubmit={value => {+ console.log('Sent:', value);+ setIsStreaming(true);+ setTimeout(() => setIsStreaming(false), 3000);+ }}+ isStreaming={isStreaming}+ onStop={() => setIsStreaming(false)}+ placeholder="Ask me anything..."+ drawer={+ <XDSChatComposerDrawer count={5}>+ <XDSToken label="design-spec.pdf" onRemove={() => {}} />+ <XDSToken label="requirements.docx" onRemove={() => {}} />+ <XDSToken label="wireframes.fig" onRemove={() => {}} />+ <XDSToken label="api-spec.yaml" onRemove={() => {}} />+ <XDSToken label="user-research.csv" onRemove={() => {}} />+ </XDSChatComposerDrawer>+ }+ headerActions={+ <>+ <XDSButton+ label="Mention"+ variant="ghost"+ size="sm"+ icon={<XDSIcon icon={AtSymbolIcon} />}+ isIconOnly+ />+ <XDSButton+ label="Attach file"+ variant="ghost"+ size="sm"+ icon={<XDSIcon icon={PaperClipIcon} />}+ isIconOnly+ />+ </>+ }+ headerContext={+ <XDSProgressBar label="Context window" value={3} isLabelHidden />+ }+ footerActions={+ <>+ <XDSDropdownMenu+ button={{+ label: 'Auto',+ variant: 'ghost',+ size: 'md',+ icon: <XDSIcon icon={SparklesIcon} size="sm" />,+ children: 'Auto',+ }}+ menuWidth={200}+ items={[+ {label: 'Auto', onClick: () => {}},+ {label: 'Model A', onClick: () => {}},+ {label: 'Model B', onClick: () => {}},+ {label: 'Model C', onClick: () => {}},+ ]}+ />+ <XDSDropdownMenu+ button={{+ label: 'Settings',+ variant: 'ghost',+ size: 'md',+ icon: <XDSIcon icon={Cog6ToothIcon} size="sm" />,+ children: 'Settings',+ }}+ menuWidth={200}+ items={[+ {label: 'Preferences', onClick: () => {}},+ {label: 'Keyboard shortcuts', onClick: () => {}},+ {label: 'About', onClick: () => {}},+ ]}+ />+ </>+ }+ sendActions={+ <XDSButton+ label="Microphone"+ variant="ghost"+ size="md"+ icon={<XDSIcon icon={MicrophoneIcon} />}+ isIconOnly+ />+ }+ />+ </XDSStack>+ );+}diff --git a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerFullFeaturedComposer.doc.mjs b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerFullFeaturedComposer.doc.mjsdeleted file mode 100644index ee83bad011..0000000000--- a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerFullFeaturedComposer.doc.mjs+++ /dev/null@@ -1,10 +0,0 @@-/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */-export const doc = {- type: 'block',- name: 'ChatComposer — Full Featured',- description:- 'Chat composer with attachment tokens, context progress bar, and footer action buttons.',- isReady: true,- aspectRatio: 4 / 3,- componentsUsed: ['ChatComposer', 'Token', 'Button', 'ProgressBar'],-};diff --git a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerFullFeaturedComposer.tsx b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerFullFeaturedComposer.tsxdeleted file mode 100644index e9618e1de6..0000000000--- a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerFullFeaturedComposer.tsx+++ /dev/null@@ -1,29 +0,0 @@-'use client';--import {XDSChatComposer, XDSChatComposerDrawer} from '@xds/core/Chat';-import {XDSToken} from '@xds/core/Token';-import {XDSButton} from '@xds/core/Button';-import {XDSProgressBar} from '@xds/core/ProgressBar';--export default function ChatComposerFullFeaturedComposer() {- return (- <XDSChatComposer- onSubmit={() => {}}- placeholder="Ask me anything..."- drawer={- <XDSChatComposerDrawer>- <XDSToken label="design-spec.pdf" onRemove={() => {}} />- </XDSChatComposerDrawer>- }- headerContext={- <XDSProgressBar label="Context window" value={3} isLabelHidden />- }- footerActions={- <>- <XDSButton label="Auto" variant="ghost" size="md" />- <XDSButton label="Settings" variant="ghost" size="md" />- </>- }- />- );-}diff --git a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerShowcase.tsx b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerShowcase.tsxindex ffc10ac6e5..b4386e0000 100644--- a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerShowcase.tsx+++ b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerShowcase.tsx@@ -1,7 +1,15 @@'use client';import {XDSChatComposer} from '@xds/core/Chat';+import {XDSStack} from '@xds/core/Layout';export default function ChatComposerShowcase() {- return <XDSChatComposer onSubmit={() => {}} />;+ return (+ <XDSStack direction="vertical" width="100%" style={{maxWidth: 450}}>+ <XDSChatComposer+ onSubmit={() => {}}+ placeholder="Type a message…"+ />+ </XDSStack>+ );}diff --git a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerSimple.doc.mjs b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerSimple.doc.mjsnew file mode 100644index 0000000000..beed7eb56f--- /dev/null+++ b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerSimple.doc.mjs@@ -0,0 +1,9 @@+/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */+export const doc = {+ type: 'block',+ name: 'ChatComposer — Simple',+ description: 'Minimal chat composer with a placeholder and submit handler. The simplest way to drop a message input into a page.',+ isReady: true,+ aspectRatio: 16 / 9,+ componentsUsed: ['ChatComposer', 'Layout'],+};diff --git a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerSimple.tsx b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerSimple.tsxnew file mode 100644index 0000000000..79462a749c--- /dev/null+++ b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerSimple.tsx@@ -0,0 +1,16 @@+'use client';++import {XDSChatComposer} from '@xds/core/Chat';+import {XDSStack} from '@xds/core/Layout';++export default function ChatComposerSimple() {+ return (+ <XDSStack direction="vertical" style={{width: '100%', maxWidth: 450}}>+ <XDSChatComposer+ onSubmit={value => {+ console.log('Sent:', value);+ }}+ />+ </XDSStack>+ );+}diff --git a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerSimpleComposer.doc.mjs b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerSimpleComposer.doc.mjsdeleted file mode 100644index ceee89daab..0000000000--- a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerSimpleComposer.doc.mjs+++ /dev/null@@ -1,10 +0,0 @@-/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */-export const doc = {- type: 'block',- name: 'ChatComposer — Simple',- description:- 'Minimal chat composer with a placeholder and submit handler.',- isReady: true,- aspectRatio: 4 / 3,- componentsUsed: ['ChatComposer'],-};diff --git a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerSimpleComposer.tsx b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerSimpleComposer.tsxdeleted file mode 100644index 985819a831..0000000000--- a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerSimpleComposer.tsx+++ /dev/null@@ -1,12 +0,0 @@-'use client';--import {XDSChatComposer} from '@xds/core/Chat';--export default function ChatComposerSimpleComposer() {- return (- <XDSChatComposer- onSubmit={() => {}}- placeholder="Type a message..."- />- );-}diff --git a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerStreaming.doc.mjs b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerStreaming.doc.mjsnew file mode 100644index 0000000000..3a265a26f2--- /dev/null+++ b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerStreaming.doc.mjs@@ -0,0 +1,9 @@+/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */+export const doc = {+ type: 'block',+ name: 'ChatComposer — Streaming',+ description: 'Chat composer with streaming state and a stop button. Use when the assistant is generating a response and the user can cancel.',+ isReady: true,+ aspectRatio: 16 / 9,+ componentsUsed: ['ChatComposer', 'Layout', 'Text'],+};diff --git a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerStreaming.tsx b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerStreaming.tsxnew file mode 100644index 0000000000..0568d41b60--- /dev/null+++ b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerStreaming.tsx@@ -0,0 +1,33 @@+'use client';++import {useState} from 'react';+import {XDSChatComposer} from '@xds/core/Chat';+import {XDSStack} from '@xds/core/Layout';+import {XDSText} from '@xds/core/Text';++export default function ChatComposerStreaming() {+ const [isStreaming, setIsStreaming] = useState(false);++ return (+ <XDSStack direction="vertical" gap={4} style={{width: '100%', maxWidth: 450}}>+ <XDSStack direction="vertical" gap={1}>+ <XDSText type="supporting" color="secondary">+ {isStreaming ? 'Streaming — click stop to cancel' : 'Send a message to start streaming'}+ </XDSText>+ <XDSChatComposer+ onSubmit={value => {+ console.log('Sent:', value);+ setIsStreaming(true);+ setTimeout(() => setIsStreaming(false), 5000);+ }}+ isStreaming={isStreaming}+ onStop={() => {+ console.log('Stopped');+ setIsStreaming(false);+ }}+ placeholder="Send a message to start streaming..."+ />+ </XDSStack>+ </XDSStack>+ );+}diff --git a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerValidation.doc.mjs b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerValidation.doc.mjsnew file mode 100644index 0000000000..8259564fa4--- /dev/null+++ b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerValidation.doc.mjs@@ -0,0 +1,9 @@+/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */+export const doc = {+ type: 'block',+ name: 'ChatComposer — Validation',+ description: 'Chat composer with error and warning status messages. Status can appear above or below the composer to surface validation or system feedback.',+ isReady: true,+ aspectRatio: 4 / 3,+ componentsUsed: ['ChatComposer', 'Layout', 'Text'],+};diff --git a/packages/cli/templates/blocks/components/ChatComposer/ChatComposerValidation.tsx b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerValidation.tsxnew file mode 100644index 0000000000..432a9d40c8--- /dev/null+++ b/packages/cli/templates/blocks/components/ChatComposer/ChatComposerValidation.tsx@@ -0,0 +1,41 @@+'use client';++import {XDSChatComposer} from '@xds/core/Chat';+import {XDSStack} from '@xds/core/Layout';+import {XDSText} from '@xds/core/Text';++export default function ChatComposerValidation() {+ return (+ <XDSStack direction="vertical" gap={4} style={{width: '100%', maxWidth: 450}}>+ <XDSStack direction="vertical" gap={1}>+ <XDSText type="supporting" color="secondary">+ Error message (with top position)+ </XDSText>+ <XDSChatComposer+ onSubmit={value => {+ console.log('Sent:', value);+ }}+ statusPosition="top"+ status={{+ type: 'error',+ message: 'Failed to send message. Please try again.',+ }}+ />+ </XDSStack>+ <XDSStack direction="vertical" gap={1}>+ <XDSText type="supporting" color="secondary">+ Warning message (with bottom position)+ </XDSText>+ <XDSChatComposer+ onSubmit={value => {+ console.log('Sent:', value);+ }}+ status={{+ type: 'warning',+ message: 'Context window is 90% full.',+ }}+ />+ </XDSStack>+ </XDSStack>+ );+}diff --git a/packages/cli/templates/blocks/components/ChatComposerDrawer/ChatComposerDrawerFollowUpQuestions.doc.mjs b/packages/cli/templates/blocks/components/ChatComposerDrawer/ChatComposerDrawerFollowUpQuestions.doc.mjsnew file mode 100644index 0000000000..b9a802fd14--- /dev/null+++ b/packages/cli/templates/blocks/components/ChatComposerDrawer/ChatComposerDrawerFollowUpQuestions.doc.mjs@@ -0,0 +1,9 @@+/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */+export const doc = {+ type: 'block',+ name: 'ChatComposerDrawer — Follow-Up Questions',+ description: 'Chat composer drawer with navigable follow-up questions and selectable lettered options. Use for multi-step clarification workflows.',+ isReady: true,+ aspectRatio: 4 / 3,+ componentsUsed: ['ChatComposer', 'Button', 'Icon', 'List', 'Badge', 'Text', 'Layout'],+};diff --git a/packages/cli/templates/blocks/components/ChatComposerDrawer/ChatComposerDrawerFollowUpQuestions.tsx b/packages/cli/templates/blocks/components/ChatComposerDrawer/ChatComposerDrawerFollowUpQuestions.tsxnew file mode 100644index 0000000000..40022e0314--- /dev/null+++ b/packages/cli/templates/blocks/components/ChatComposerDrawer/ChatComposerDrawerFollowUpQuestions.tsx@@ -0,0 +1,114 @@+'use client';++import {useState} from 'react';+import {XDSChatComposer, XDSChatComposerDrawer} from '@xds/core/Chat';+import {XDSButton} from '@xds/core/Button';+import {XDSIcon} from '@xds/core/Icon';+import {XDSList, XDSListItem} from '@xds/core/List';+import {XDSText} from '@xds/core/Text';+import {XDSBadge} from '@xds/core/Badge';+import {XDSStack} from '@xds/core/Layout';+import {ChevronLeftIcon, ChevronRightIcon} from '@heroicons/react/24/outline';++const questions = [+ {+ question: 'Which environment should this deploy to?',+ options: [+ {key: 'A', label: 'Production (requires approval)'},+ {key: 'B', label: 'Staging'},+ {key: 'C', label: 'Local development only'},+ ],+ },+ {+ question:+ 'This will modify 12 files. How should I handle breaking changes?',+ options: [+ {key: 'A', label: 'Add a migration and keep backward compatibility'},+ {+ key: 'B',+ label: 'Breaking change is fine \u2014 bump the major version',+ },+ ],+ },+ {+ question: 'I found 3 existing implementations. Which one should I extend?',+ options: [+ {key: 'A', label: 'UserService in src/services/ (most recent)'},+ {key: 'B', label: 'UserManager in src/legacy/ (has more test coverage)'},+ {key: 'C', label: 'Neither \u2014 start fresh'},+ ],+ },+];++export default function ChatComposerDrawerFollowUpQuestions() {+ const [currentQ, setCurrentQ] = useState(0);+ const [answers, setAnswers] = useState<Record<number, string>>({});+ const q = questions[currentQ];+ const selected = answers[currentQ] ?? null;++ return (+ <XDSStack direction="vertical" style={{width: '100%', maxWidth: 450}}>+ <XDSChatComposer+ onSubmit={value => {+ console.log('Submit:', value, '| Answers:', answers);+ }}+ placeholder="Or describe what you need in your own words\u2026"+ drawer={+ <XDSChatComposerDrawer count={questions.length} label="Questions">+ <XDSStack direction="vertical" gap={1} width="100%">+ <XDSStack direction="horizontal" hAlign="between" vAlign="center">+ <XDSButton+ label="Previous question"+ variant="ghost"+ size="sm"+ icon={<XDSIcon icon={ChevronLeftIcon} />}+ isIconOnly+ isDisabled={currentQ === 0}+ onClick={() => setCurrentQ(i => i - 1)}+ />+ <XDSText color="secondary">+ {currentQ + 1} of {questions.length}+ </XDSText>+ <XDSButton+ label="Next question"+ variant="ghost"+ size="sm"+ icon={<XDSIcon icon={ChevronRightIcon} />}+ isIconOnly+ isDisabled={currentQ === questions.length - 1}+ onClick={() => setCurrentQ(i => i + 1)}+ />+ </XDSStack>+ <XDSList>+ <XDSListItem+ label={+ <XDSText weight="bold">+ {currentQ + 1}. {q.question}+ </XDSText>+ }+ />+ {q.options.map(opt => (+ <XDSListItem+ key={opt.key}+ label={opt.label}+ startContent={+ <XDSBadge+ variant={selected === opt.key ? 'info' : 'neutral'}+ label={opt.key}+ />+ }+ isSelected={selected === opt.key}+ onClick={() =>+ setAnswers(prev => ({...prev, [currentQ]: opt.key}))+ }+ />+ ))}+ </XDSList>+ </XDSStack>+ </XDSChatComposerDrawer>+ }+ footerActions={<XDSButton label="Skip all" variant="ghost" size="md" />}+ />+ </XDSStack>+ );+}diff --git a/packages/core/src/Chat/Chat.doc.mjs b/packages/core/src/Chat/Chat.doc.mjsindex 9d97723198..b1223094bf 100644--- a/packages/core/src/Chat/Chat.doc.mjs+++ b/packages/core/src/Chat/Chat.doc.mjs@@ -167,14 +167,26 @@ export const docs = {},],usage: {- description: 'Chat components provide layout primitives and a message composer for building AI chat interfaces. Use Chat components when building conversational UIs that need message display, sender-aware styling, and rich input with trigger menus and attachments.',+ description: 'Chat components provide layout primitives and a message composer for building AI chat interfaces. XDSChatComposer is the input shell — compose it using named slots (drawer, headerActions, footerActions, sendActions) to assemble features like file attachments, model selectors, and context indicators without building custom layout. Use Chat components when building conversational UIs that need message display, sender-aware styling, and rich input with trigger menus and attachments.',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 (drawer, headerActions, footerActions) to keep the input layout structured and extensible.' },+ { guidance: true, description: 'Use the named slots on XDSChatComposer (drawer, headerActions, footerActions, sendActions) to keep the input layout structured. Each slot has a specific position and purpose.' },+ { guidance: true, description: 'Show the streaming state with isStreaming and provide an onStop handler so users can cancel long-running responses.' },{ 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: 'Don\'t build custom input containers or composer chrome — XDSChatComposer handles the border radius, shadows, focus ring, and slot layout. Customise through slots, not wrapping.' },{ guidance: false, description: 'Don\'t 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: 'Don\'t build your own scroll management or density breakpoints — XDSChatLayout handles both via container width observation.' },+ { guidance: false, description: 'Don\'t use the status prop for transient success messages — it\'s for errors and warnings that need the user\'s attention before they send another message.' },+ ],+ anatomy: [+ { name: 'Drawer', required: false, description: 'Collapsible area above the input for file tokens, context chips, or other attachments. Use XDSChatComposerDrawer.' },+ { name: 'Header actions', required: false, description: 'Left-aligned icon buttons above the input — attach file, mention, etc. Use icon-only size="sm" buttons.' },+ { name: 'Header context', required: false, description: 'Right-aligned contextual info — context window progress bar, model info, supporting text.' },+ { name: 'Input', required: true, description: 'The text input area. Uses a built-in textarea by default, or replace with XDSChatComposerInput for trigger menus and tokens.' },+ { name: 'Footer actions', required: false, description: 'Left-aligned buttons below the input — model selector, settings, etc.' },+ { name: 'Send actions', required: false, description: 'Actions to the left of the send button — microphone, voice input, etc.' },+ { name: 'Send button', required: false, description: 'Circular send/stop toggle. Built-in by default; toggles between send and stop based on isStreaming.' },+ { name: 'Status', required: false, description: 'Error or warning message rendered above or below the composer.' },],},};@@ -207,14 +219,16 @@ docs.components.push(chatLayoutScrollButtonComponent);/** @type {import('../docs-types').TranslationDoc} */export const docsZh = {usage: {- description: 'Chat components provide layout primitives and a message composer for building AI chat interfaces. Use Chat components when building conversational UIs that need message display, sender-aware styling, and rich input with trigger menus and attachments.',+ description: 'Chat components provide layout primitives and a message composer for building AI chat interfaces. XDSChatComposer is the input shell — compose it using named slots (drawer, headerActions, footerActions, sendActions) to assemble features like file attachments, model selectors, and context indicators without building custom layout. Use Chat components when building conversational UIs that need message display, sender-aware styling, and rich input with trigger menus and attachments.',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 (drawer, headerActions, footerActions) to keep the input layout structured and extensible.' },+ { guidance: true, description: 'Use the named slots on XDSChatComposer (drawer, headerActions, footerActions, sendActions) to keep the input layout structured. Each slot has a specific position and purpose.' },+ { guidance: true, description: 'Show the streaming state with isStreaming and provide an onStop handler so users can cancel long-running responses.' },{ 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: 'Don\'t build custom input containers or composer chrome — XDSChatComposer handles the border radius, shadows, focus ring, and slot layout. Customise through slots, not wrapping.' },{ guidance: false, description: 'Don\'t 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: 'Don\'t build your own scroll management or density breakpoints — XDSChatLayout handles both via container width observation.' },+ { guidance: false, description: 'Don\'t use the status prop for transient success messages — it\'s for errors and warnings that need the user\'s attention before they send another message.' },],},components: [@@ -366,14 +380,16 @@ 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 message composer for building AI chat interfaces. Use Chat components when building conversational UIs that need message display, sender-aware styling, and rich input with trigger menus and attachments.',+ description: 'Chat layout primitives + composer for AI chat UIs. Composer is a slot-based shell — drawer, headerActions, footerActions, sendActions. Use Chat components for conversational UIs w/ message display, sender-aware styling, rich input.',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 (drawer, headerActions, footerActions) to keep the input layout structured and extensible.' },- { 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: 'Don\'t 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: 'Don\'t build your own scroll management or density breakpoints — XDSChatLayout handles both via container width observation.' },+ { guidance: true, description: 'MessageList > Message > Bubble for sender-aware styling.' },+ { guidance: true, description: 'Named slots on Composer (drawer, headerActions, footerActions, sendActions) — each has a specific position.' },+ { guidance: true, description: 'isStreaming + onStop for cancelable long-running responses.' },+ { guidance: true, description: 'Name/metadata on bubble if bubble boundary, on message wrapper if raw content.' },+ { guidance: true, description: 'XDSChatLayout for full-page — auto-scroll, density adaptation, composer docking.' },+ { guidance: false, description: 'Custom composer chrome — Composer handles radius, shadows, focus ring. Use slots.' },+ { guidance: false, description: 'Metadata/names on both bubble and wrapper — pick one.' },+ { guidance: false, description: 'Status for success toasts — it\'s for errors/warnings before next send.' },],},components: [