Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

Improve ChatComposerInput docs page and block examples (#1855)

Kenton Quatman04f25da9b0da
diff --git a/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputControlledInput.doc.mjs b/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputControlledInput.doc.mjs
index d8ddaf777b..7a65cf532d 100644
--- a/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputControlledInput.doc.mjs
+++ b/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputControlledInput.doc.mjs
@@ -3,8 +3,8 @@ export const doc = {
type: 'block',
name: 'ChatComposerInput — Controlled',
description:
- 'Controlled chat input with live value display, showing two-way binding between composer and input.',
+ 'Controlled chat input with live value display. Use controlled mode when you need to read or transform the input value outside the composer.',
isReady: true,
- aspectRatio: 4 / 3,
- componentsUsed: ['ChatComposer', 'ChatComposerInput'],
+ aspectRatio: 16 / 9,
+ componentsUsed: ['ChatComposer', 'ChatComposerInput', 'Layout', 'Text'],
};
diff --git a/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputControlledInput.tsx b/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputControlledInput.tsx
index 706d1f5dad..eb119bc1eb 100644
--- a/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputControlledInput.tsx
+++ b/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputControlledInput.tsx
@@ -2,11 +2,13 @@
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 (
- <div style={{display: 'flex', flexDirection: 'column', gap: 12}}>
+ <XDSStack direction="vertical" gap={3} style={{width: '100%', maxWidth: 450}}>
<XDSChatComposer
onSubmit={() => setValue('')}
value={value}
@@ -19,9 +21,9 @@ export default function ChatComposerInputControlledInput() {
/>
}
/>
- <div style={{fontSize: 12, fontFamily: 'monospace', color: '#888'}}>
+ <XDSText type="supporting" color="secondary">
Value: {JSON.stringify(value)}
- </div>
- </div>
+ </XDSText>
+ </XDSStack>
);
}
diff --git a/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputDisabled.doc.mjs b/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputDisabled.doc.mjs
new file mode 100644
index 0000000000..7f06893f3c
--- /dev/null
+++ b/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputDisabled.doc.mjs
@@ -0,0 +1,10 @@
+/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */
+export const doc = {
+ type: 'block',
+ name: 'ChatComposerInput — Disabled',
+ description:
+ 'Composer in a disabled state. Use when the input should be visible but not interactive, such as during streaming or when a prerequisite is unmet.',
+ isReady: true,
+ aspectRatio: 16 / 9,
+ componentsUsed: ['ChatComposer', 'ChatComposerInput', 'Layout'],
+};
diff --git a/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputDisabled.tsx b/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputDisabled.tsx
new file mode 100644
index 0000000000..f2816f2d9e
--- /dev/null
+++ b/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputDisabled.tsx
@@ -0,0 +1,18 @@
+'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>
+ );
+}
diff --git a/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputMentionTrigger.doc.mjs b/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputMentionTrigger.doc.mjs
index 5250e1afac..75c017450e 100644
--- a/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputMentionTrigger.doc.mjs
+++ b/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputMentionTrigger.doc.mjs
@@ -1,10 +1,10 @@
/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */
export const doc = {
type: 'block',
- name: 'ChatComposerInput — Mention Trigger',
+ name: 'ChatComposerInput — Mentions',
description:
- 'Chat input with @ mention trigger that shows a typeahead menu with user names and roles.',
+ 'Chat input with an @ trigger that opens a typeahead menu for mentioning users. Selected names appear as inline tokens.',
isReady: true,
- aspectRatio: 4 / 3,
- componentsUsed: ['ChatComposer', 'ChatComposerInput', 'Typeahead'],
+ aspectRatio: 16 / 9,
+ componentsUsed: ['ChatComposer', 'ChatComposerInput', 'Typeahead', 'Layout', 'Text'],
};
diff --git a/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputMentionTrigger.tsx b/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputMentionTrigger.tsx
index 34c7eca16d..a3eb458d5d 100644
--- a/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputMentionTrigger.tsx
+++ b/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputMentionTrigger.tsx
@@ -9,6 +9,8 @@ import {
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'}},
@@ -39,7 +41,7 @@ export default function ChatComposerInputMentionTrigger() {
};
return (
- <div style={{display: 'flex', flexDirection: 'column', gap: 16}}>
+ <XDSStack direction="vertical" gap={3} style={{width: '100%', maxWidth: 450}}>
<XDSChatComposer
onSubmit={() => setValue('')}
input={
@@ -51,9 +53,9 @@ export default function ChatComposerInputMentionTrigger() {
/>
}
/>
- <div style={{fontSize: 12, fontFamily: 'monospace', color: '#888'}}>
+ <XDSText type="supporting" color="secondary">
Value: {JSON.stringify(value)}
- </div>
- </div>
+ </XDSText>
+ </XDSStack>
);
}
diff --git a/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputMultipleTriggers.doc.mjs b/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputMultipleTriggers.doc.mjs
new file mode 100644
index 0000000000..cb5c52688d
--- /dev/null
+++ b/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputMultipleTriggers.doc.mjs
@@ -0,0 +1,10 @@
+/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */
+export const doc = {
+ type: 'block',
+ name: 'ChatComposerInput — Multiple Triggers',
+ description:
+ 'Chat input with both @ mentions and / commands. Each trigger type renders tokens in a distinct color so users can tell them apart at a glance.',
+ isReady: true,
+ aspectRatio: 16 / 9,
+ componentsUsed: ['ChatComposer', 'ChatComposerInput', 'Typeahead', 'Layout', 'Text'],
+};
diff --git a/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputMultipleTriggers.tsx b/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputMultipleTriggers.tsx
new file mode 100644
index 0000000000..cc209a1d2b
--- /dev/null
+++ b/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputMultipleTriggers.tsx
@@ -0,0 +1,75 @@
+'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>
+ );
+}
diff --git a/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputShowcase.doc.mjs b/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputShowcase.doc.mjs
index 590bfbb8bc..c9ecde5ea6 100644
--- a/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputShowcase.doc.mjs
+++ b/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputShowcase.doc.mjs
@@ -3,6 +3,7 @@ export const doc = {
type: 'block',
name: 'ChatComposerInput',
isReady: true,
- aspectRatio: 4 / 3,
+ aspectRatio: 16 / 9,
isShowcase: true,
+ componentsUsed: ['ChatComposer', 'ChatComposerInput', 'Layout'],
};
diff --git a/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputShowcase.tsx b/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputShowcase.tsx
index df23581975..fd81230344 100644
--- a/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputShowcase.tsx
+++ b/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputShowcase.tsx
@@ -1,14 +1,17 @@
'use client';
import {XDSChatComposer, XDSChatComposerInput} from '@xds/core/Chat';
+import {XDSStack} from '@xds/core/Layout';
export default function ChatComposerInputShowcase() {
return (
- <XDSChatComposer
- onSubmit={() => {}}
- input={
- <XDSChatComposerInput placeholder="Ask me anything about XDS..." />
- }
- />
+ <XDSStack direction="vertical" style={{width: '100%', maxWidth: 450}}>
+ <XDSChatComposer
+ onSubmit={() => {}}
+ input={
+ <XDSChatComposerInput placeholder="Ask me anything about XDS..." />
+ }
+ />
+ </XDSStack>
);
}
diff --git a/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputSlashCommands.doc.mjs b/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputSlashCommands.doc.mjs
index f5c486601b..0537075787 100644
--- a/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputSlashCommands.doc.mjs
+++ b/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputSlashCommands.doc.mjs
@@ -3,8 +3,8 @@ export const doc = {
type: 'block',
name: 'ChatComposerInput — Slash Commands',
description:
- 'Chat input with / command trigger that shows a typeahead menu with command descriptions.',
+ 'Chat input with a / trigger for command selection. Use for AI assistants or bots that support structured commands.',
isReady: true,
- aspectRatio: 4 / 3,
- componentsUsed: ['ChatComposer', 'ChatComposerInput', 'Typeahead'],
+ aspectRatio: 16 / 9,
+ componentsUsed: ['ChatComposer', 'ChatComposerInput', 'Typeahead', 'Layout'],
};
diff --git a/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputSlashCommands.tsx b/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputSlashCommands.tsx
index 9125c23332..236fc4ed74 100644
--- a/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputSlashCommands.tsx
+++ b/packages/cli/templates/blocks/components/ChatComposerInput/ChatComposerInputSlashCommands.tsx
@@ -8,6 +8,7 @@ import {
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'}},
@@ -37,14 +38,16 @@ export default function ChatComposerInputSlashCommands() {
};
return (
- <XDSChatComposer
- onSubmit={() => {}}
- input={
- <XDSChatComposerInput
- triggers={[commandTrigger]}
- placeholder="Type / for commands..."
- />
- }
- />
+ <XDSStack direction="vertical" style={{width: '100%', maxWidth: 450}}>
+ <XDSChatComposer
+ onSubmit={() => {}}
+ input={
+ <XDSChatComposerInput
+ triggers={[commandTrigger]}
+ placeholder="Type / for commands..."
+ />
+ }
+ />
+ </XDSStack>
);
}
diff --git a/packages/core/src/Chat/Chat.doc.mjs b/packages/core/src/Chat/Chat.doc.mjs
index 935385d289..54e33e3409 100644
--- a/packages/core/src/Chat/Chat.doc.mjs
+++ b/packages/core/src/Chat/Chat.doc.mjs
@@ -91,7 +91,7 @@ export const docs = {
{name: 'isStreaming', type: 'boolean', description: 'Whether the assistant is currently streaming.', default: 'false'},
{name: 'value', type: 'string', description: 'Controlled input value.'},
{name: 'onChange', type: '(value: string) => void', description: 'Change handler for controlled mode.'},
- {name: 'placeholder', type: 'string', description: 'Placeholder text.', default: "'Type a message\u2026'"},
+ {name: 'placeholder', type: 'string', description: 'Placeholder text shown when the input is empty.', default: "'Type a message\u2026'"},
{name: 'isDisabled', type: 'boolean', description: 'Disables the composer.', default: 'false'},
{name: 'density', type: "'compact' | 'balanced' | 'spacious'", description: 'Visual density.', default: "'balanced'"},
{name: 'drawer', type: 'ReactNode', description: 'Slot: collapsible drawer above the input — attachments, context chips, etc. Use XDSChatComposerDrawer.'},
@@ -107,21 +107,21 @@ export const docs = {
},
{
name: 'XDSChatComposerInput',
- description: 'ContentEditable-based rich input with trigger menus (@ mentions, / commands), inline tokens, serialization, message history, and paste/drop file handling. Uses XDSSearchSource for search. Exposes an imperative handle for programmatic control.',
+ description: 'Rich text input for the chat composer. Supports trigger menus (type @ or / to open a typeahead), inline tokens rendered as badges, message history recall with ArrowUp/Down, and paste/drop file handling. Pass it to XDSChatComposer\'s input slot when you need more than a plain textarea.',
props: [
- {name: 'ref', type: 'React.Ref<XDSChatComposerInputHandle>', description: 'Imperative handle ref exposing insertToken, insertText, focus, and getValue.'},
- {name: 'value', type: 'string', description: 'Controlled value.'},
- {name: 'onChange', type: '(value: string) => void', description: 'Change handler.'},
- {name: 'placeholder', type: 'string', description: 'Placeholder text.', default: "'Type a message\u2026'"},
- {name: 'maxRows', type: 'number', description: 'Max rows before scrolling.', default: '8'},
- {name: 'triggers', type: 'XDSChatComposerTrigger[]', description: 'Trigger definitions for menus. Each trigger has a character, searchSource, and onSelect.'},
- {name: 'debounceMs', type: 'number', description: 'Debounce for async search sources.', default: '150'},
- {name: 'hasHistory', type: 'boolean', description: 'Enable ArrowUp/Down message recall.', default: 'true'},
- {name: 'label', type: 'string', description: 'Accessible label.', default: "'Message input'"},
- {name: 'isDisabled', type: 'boolean', description: 'Disabled state.', default: 'false'},
- {name: 'onPaste', type: '(event, text) => void', description: 'Paste handler.'},
- {name: 'onFiles', type: '(files: File[]) => void', description: 'File drop/paste handler.'},
- {name: 'onSubmit', type: '(value: string) => void', description: 'Submit handler (Enter without Shift).'},
+ {name: 'ref', type: 'React.Ref<XDSChatComposerInputHandle>', description: 'Imperative handle for programmatic control — insertToken, insertText, focus, and getValue.'},
+ {name: 'value', type: 'string', description: 'Controlled input value. Pair with onChange for two-way binding.'},
+ {name: 'onChange', type: '(value: string) => void', description: 'Called when the input value changes. The serialized string includes token placeholders.'},
+ {name: 'placeholder', type: 'string', description: 'Placeholder text shown when the input is empty.', default: "'Type a message\u2026'"},
+ {name: 'maxRows', type: 'number', description: 'Maximum visible rows before the input scrolls. Use a lower value in compact layouts.', default: '8'},
+ {name: 'triggers', type: 'XDSChatComposerTrigger[]', description: 'Trigger definitions for typeahead menus. Each trigger specifies a character (@ or /), a search source, and an onSelect handler that returns the token to insert.'},
+ {name: 'debounceMs', type: 'number', description: 'Debounce delay for async search sources to avoid excessive network requests.', default: '150'},
+ {name: 'hasHistory', type: 'boolean', description: 'Enable ArrowUp/Down to recall previously submitted messages.', default: 'true'},
+ {name: 'label', type: 'string', description: 'Accessible label announced by screen readers.', default: "'Message input'"},
+ {name: 'isDisabled', type: 'boolean', description: 'Disables the input. Use during streaming or when a prerequisite is unmet.', default: 'false'},
+ {name: 'onPaste', type: '(event, text) => void', description: 'Called when text is pasted. Use to intercept or transform pasted content.'},
+ {name: 'onFiles', type: '(files: File[]) => void', description: 'Called when files are pasted or dropped onto the input. Use to handle attachments.'},
+ {name: 'onSubmit', type: '(value: string) => void', description: 'Called when the user presses Enter without Shift. The serialized value includes token placeholders.'},
],
},
{
@@ -178,7 +178,7 @@ export const docs = {
},
],
usage: {
- 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.',
+ 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 XDSChatComposerInput inside XDSChatComposer for rich text entry with trigger menus, inline tokens, and message history.',
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, sendActions) to keep the input layout structured. Each slot has a specific position and purpose.' },
@@ -197,6 +197,9 @@ export const docs = {
{ guidance: false, description: 'Don\'t use XDSChatSystemMessage for sender content — it has no avatar, alignment, or bubble. Use XDSChatMessage with a sender role instead.' },
{ guidance: false, description: 'Don\'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.' },
{ guidance: false, description: 'Don\'t nest XDSChatMessage inside another XDSChatMessage — each message is a standalone article element with its own sender context.' },
+ { guidance: true, description: 'Pass XDSChatComposerInput to the composer\'s input slot when you need trigger menus, inline tokens, or file paste handling \u2014 the default textarea does not support these.' },
+ { guidance: true, description: 'Give each trigger character a distinct token color (e.g. blue for @mentions, yellow for /commands) so users can distinguish trigger types at a glance.' },
+ { guidance: false, description: 'Don\'t build a custom contenteditable input for mentions or commands \u2014 XDSChatComposerInput handles cursor management, serialization, and token rendering.' },
{ guidance: false, description: 'Don\'t mix filled and ghost bubble variants within the same sender\'s messages — pick one style per side and use it consistently.' },
{ guidance: true, description: 'Provide a `count` on XDSChatComposerDrawer that matches the number of children, and set a descriptive `label` like "Attachments" instead of the default "Items".' },
@@ -241,7 +244,7 @@ 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. 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.',
+ 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 XDSChatComposerInput inside XDSChatComposer for rich text entry with trigger menus, inline tokens, and message history.',
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, sendActions) to keep the input layout structured. Each slot has a specific position and purpose.' },
@@ -260,6 +263,9 @@ export const docsZh = {
{ guidance: false, description: 'Don\'t use XDSChatSystemMessage for sender content — it has no avatar, alignment, or bubble. Use XDSChatMessage with a sender role instead.' },
{ guidance: false, description: 'Don\'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.' },
{ guidance: false, description: 'Don\'t nest XDSChatMessage inside another XDSChatMessage — each message is a standalone article element with its own sender context.' },
+ { guidance: true, description: 'Pass XDSChatComposerInput to the composer\'s input slot when you need trigger menus, inline tokens, or file paste handling \u2014 the default textarea does not support these.' },
+ { guidance: true, description: 'Give each trigger character a distinct token color (e.g. blue for @mentions, yellow for /commands) so users can distinguish trigger types at a glance.' },
+ { guidance: false, description: 'Don\'t build a custom contenteditable input for mentions or commands \u2014 XDSChatComposerInput handles cursor management, serialization, and token rendering.' },
{ guidance: false, description: 'Don\'t mix filled and ghost bubble variants within the same sender\'s messages — pick one style per side and use it consistently.' },
{ guidance: true, description: 'Provide a `count` on XDSChatComposerDrawer that matches the number of children, and set a descriptive `label` like "Attachments" instead of the default "Items".' },
@@ -320,8 +326,8 @@ export const docsZh = {
onStop: '用户请求停止生成时调用。',
isStreaming: '助手是否正在流式输出。',
value: '受控输入值。',
- onChange: '受控模式的变更处理器。',
- placeholder: '占位文本。',
+ onChange: '受控模式的输入值变更时调用。序列化字符串包含标记占位符。',
+ placeholder: '输入为空时显示的占位文本。',
isDisabled: '禁用编写器。',
density: '视觉密度。',
drawer: '插槽:输入上方的可折叠抽屉——附件、上下文标签等。使用 XDSChatComposerDrawer。',
@@ -338,21 +344,21 @@ export const docsZh = {
{
name: 'XDSChatComposerInput',
description:
- '基于 ContentEditable 的富文本输入,支持触发菜单(@ 提及、/ 命令)、内联标记、序列化、消息历史和粘贴/拖放文件处理。提供命令式句柄用于编程式控制。',
+ '聊天编写器的富文本输入。支持触发菜单(输入 @ 或 / 打开 typeahead)、内联标记徽章、ArrowUp/Down 消息历史回溯、粘贴/拖放文件处理。当需要普通文本区域以外的功能时,传入 XDSChatComposer 的 input 插槽。',
propDescriptions: {
- ref: '命令式句柄引用,暴露 insertToken、insertText、focus 和 getValue。',
- value: '受控值。',
- onChange: '变更处理器。',
- placeholder: '占位文本。',
- maxRows: '滚动前的最大行数。',
- triggers: '菜单的触发定义。每个触发器有 character、searchSource 和 onSelect。',
- debounceMs: '异步搜索源的去抖动延迟。',
- hasHistory: '启用 ArrowUp/Down 消息回溯。',
- label: '无障碍标签。',
- isDisabled: '禁用状态。',
- onPaste: '粘贴处理器。',
- onFiles: '文件拖放/粘贴处理器。',
- onSubmit: '提交处理器(不按 Shift 的 Enter)。',
+ ref: '命令式句柄,用于编程式控制 — insertToken、insertText、focus 和 getValue。',
+ value: '受控输入值。与 onChange 配对实现双向绑定。',
+ onChange: '输入值变更时调用。序列化字符串包含标记占位符。',
+ placeholder: '输入为空时显示的占位文本。',
+ maxRows: '滚动前的最大可见行数。紧凑布局中使用较小值。',
+ triggers: '菜单的触发定义。每个触发器指定字符(@ 或 /)、搜索源和返回要插入标记的 onSelect 处理器。',
+ debounceMs: '异步搜索源的去抖动延迟,避免过多网络请求。',
+ hasHistory: '启用 ArrowUp/Down 回溯之前提交的消息。',
+ label: '屏幕阅读器播报的无障碍标签。',
+ isDisabled: '禁用输入。在流式输出期间或前置条件未满足时使用。',
+ onPaste: '粘贴文本时调用。用于拦截或转换粘贴内容。',
+ onFiles: '粘贴或拖放文件到输入时调用。用于处理附件。',
+ onSubmit: '用户不按 Shift 按 Enter 时调用。序列化值包含标记占位符。',
},
},
{
@@ -420,9 +426,9 @@ export const docsZh = {
/** @type {import('../docs-types').TranslationDoc} */
export const docsDense = {
- description: 'AI chat components. Layout (MessageList>Message>Bubble+SystemMessage) + Composer (shell w/ slots, ContentEditable input w/ trigger menus, attachments)',
+ description: 'AI chat components. Layout (MessageList>Message>Bubble+SystemMessage) + Composer (shell w/ slots, ContentEditable input w/ trigger menus, tokens, msg history, attachments)',
usage: {
- 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.',
+ description: 'Chat layout primitives + composer for AI chat UIs. Composer is a slot-based shell — drawer, headerActions, footerActions, sendActions. XDSChatComposerInput for trigger menus, inline tokens, and message history.',
bestPractices: [
{ 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.' },
@@ -438,6 +444,9 @@ export const docsDense = {
{ guidance: false, description: 'Status for success toasts — it\'s for errors/warnings before next send.' },
{ guidance: false, description: 'SystemMessage for sender content — no avatar/alignment/bubble. Use ChatMessage instead.' },
{ guidance: false, description: 'Long/multi-line system messages — keep to a single short sentence.' },
+ { guidance: true, description: 'XDSChatComposerInput in input slot for trigger menus, tokens, file paste.' },
+ { guidance: true, description: 'Distinct token colors per trigger type \u2014 blue @mentions, yellow /commands.' },
+ { guidance: false, description: 'Custom contenteditable for mentions/commands \u2014 XDSChatComposerInput handles it.' },
{ guidance: false, description: 'Nesting XDSChatMessage inside another — each is a standalone article.' },
{ guidance: false, description: 'Mix filled and ghost variants in same sender\'s messages — pick one style per side.' },
@@ -508,8 +517,8 @@ export const docsDense = {
isStreaming: 'assistant streaming state',
value: 'controlled input value',
onChange: 'controlled change handler',
- placeholder: 'placeholder text',
- isDisabled: 'disabled state',
+ placeholder: 'placeholder when empty',
+ isDisabled: 'disabled; use during streaming or unmet prereqs',
density: 'visual density',
drawer: 'slot: collapsible drawer above input — attachments, context chips, etc.; use XDSChatComposerDrawer',
headerActions: 'slot: left header actions (attach, mention); icon-only sm buttons',
@@ -524,21 +533,21 @@ export const docsDense = {
},
{
name: 'XDSChatComposerInput',
- description: 'ContentEditable rich input w/ trigger menus (@/commands), inline tokens, serialization, msg history, paste/drop files, imperative handle',
+ description: 'rich input for composer; trigger menus (@/commands), inline tokens, msg history, paste/drop files. Use in XDSChatComposer input slot when you need more than plain textarea.',
propDescriptions: {
- ref: 'imperative handle ref (insertToken/insertText/focus/getValue)',
- value: 'controlled value',
- onChange: 'change handler',
- placeholder: 'placeholder text',
- maxRows: 'max rows before scrolling',
- triggers: 'trigger defs for menus; each has character+searchSource+onSelect',
- debounceMs: 'debounce for async search sources',
- hasHistory: 'ArrowUp/Down msg recall',
- label: 'a11y label',
- isDisabled: 'disabled state',
- onPaste: 'paste handler',
- onFiles: 'file drop/paste handler',
- onSubmit: 'submit handler (Enter w/o Shift)',
+ ref: 'imperative handle (insertToken/insertText/focus/getValue)',
+ value: 'controlled value; pair w/ onChange for two-way binding',
+ onChange: 'value change handler; serialized string includes token placeholders',
+ placeholder: 'placeholder when empty',
+ maxRows: 'max visible rows before scroll; lower for compact layouts',
+ triggers: 'typeahead trigger defs; character(@/)+searchSource+onSelect returning token',
+ debounceMs: 'debounce for async search to avoid excess requests',
+ hasHistory: 'ArrowUp/Down to recall previous submissions',
+ label: 'a11y label for screen readers',
+ isDisabled: 'disabled; use during streaming or unmet prereqs',
+ onPaste: 'paste handler; intercept/transform pasted content',
+ onFiles: 'file paste/drop handler; use for attachments',
+ onSubmit: 'Enter w/o Shift handler; serialized value includes token placeholders',
},
},
{