Skip to content

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

TypeScript

Example cleanup (#1779)

Kenton Quatman4349de7b3f8d
diff --git a/packages/cli/templates/blocks/components/Chat/ChatComposer.tsx b/packages/cli/templates/blocks/components/Chat/ChatComposer.tsx
index d6cdde666b..bff8b9028a 100644
--- a/packages/cli/templates/blocks/components/Chat/ChatComposer.tsx
+++ b/packages/cli/templates/blocks/components/Chat/ChatComposer.tsx
@@ -1,59 +1,95 @@
'use client';
-import {XDSChatComposer} from '@xds/core/Chat';
+import {useState} from 'react';
+import {
+ XDSChatComposer,
+ XDSChatComposerDrawer,
+ XDSChatComposerInput,
+} from '@xds/core/Chat';
import {XDSButton} from '@xds/core/Button';
+import {XDSToken} from '@xds/core/Token';
+import {XDSIcon} from '@xds/core/Icon';
+import {XDSDropdownMenu} from '@xds/core/DropdownMenu';
import {XDSStack} from '@xds/core/Layout';
-import {XDSText} from '@xds/core/Text';
+import {XDSProgressBar} from '@xds/core/ProgressBar';
+import {
+ AtSymbolIcon,
+ CodeBracketIcon,
+ ListBulletIcon,
+ PaperClipIcon,
+ SparklesIcon,
+} from '@heroicons/react/24/outline';
+
+const MODES = [
+ {label: 'Auto', icon: SparklesIcon},
+ {label: 'Code', icon: CodeBracketIcon},
+ {label: 'Plan', icon: ListBulletIcon},
+];
export default function ChatComposer() {
+ const [mode, setMode] = useState(MODES[0]);
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>
+ <XDSStack direction="vertical" gap={4} width={450}>
<XDSChatComposer
onSubmit={() => {}}
- placeholder="Ask me anything…"
+ input={<XDSChatComposerInput style={{minHeight: 66}} />}
+ drawer={
+ <XDSChatComposerDrawer count={2}>
+ <XDSToken label="report.pdf" onRemove={() => {}} />
+ <XDSToken label="data.csv" onRemove={() => {}} />
+ </XDSChatComposerDrawer>
+ }
+ headerContext={
+ <XDSProgressBar label="Context window" value={42} isLabelHidden />
+ }
+ headerActions={
+ <>
+ <XDSButton
+ label="Mention"
+ variant="ghost"
+ size="sm"
+ icon={<XDSIcon icon={AtSymbolIcon} size="sm" />}
+ isIconOnly
+ onClick={() => {}}
+ />
+ <XDSButton
+ label="Attach"
+ variant="ghost"
+ size="sm"
+ icon={<XDSIcon icon={PaperClipIcon} size="sm" />}
+ isIconOnly
+ onClick={() => {}}
+ />
+ </>
+ }
footerActions={
<>
- <XDSButton label="Auto" variant="ghost" size="md" />
- <XDSButton label="Settings" variant="ghost" size="md" />
+ <XDSDropdownMenu
+ button={{
+ label: mode.label,
+ variant: 'ghost',
+ size: 'md',
+ icon: <XDSIcon icon={mode.icon} size="sm" />,
+ }}
+ menuWidth={120}
+ items={MODES.map((m) => ({
+ label: m.label,
+ icon: m.icon,
+ onClick: () => setMode(m),
+ }))}
+ />
+ <XDSDropdownMenu
+ button={{label: 'Settings', variant: 'ghost', size: 'md'}}
+ menuWidth={180}
+ items={[
+ {label: 'Personalization', onClick: () => {}},
+ {label: 'Memory & history', onClick: () => {}},
+ {label: 'Data controls', onClick: () => {}},
+ ]}
+ />
</>
}
/>
- </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.tsx b/packages/cli/templates/blocks/components/Chat/ChatComposerAttachments.tsx
index 0c33c14252..f24ec5abcf 100644
--- a/packages/cli/templates/blocks/components/Chat/ChatComposerAttachments.tsx
+++ b/packages/cli/templates/blocks/components/Chat/ChatComposerAttachments.tsx
@@ -5,45 +5,42 @@ import {XDSToken} from '@xds/core/Token';
import {XDSProgressBar} from '@xds/core/ProgressBar';
import {XDSStack} from '@xds/core/Layout';
import {XDSText} from '@xds/core/Text';
+import {XDSButton} from '@xds/core/Button';
+import {XDSIcon} from '@xds/core/Icon';
+import {PaperClipIcon, AtSymbolIcon} from '@heroicons/react/24/outline';
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={() => {}}
- drawer={
- <XDSChatComposerDrawer>
- <XDSToken label="report.pdf" onRemove={() => {}} />
- <XDSToken label="data.csv" onRemove={() => {}} />
- </XDSChatComposerDrawer>
- }
- 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={() => {}}
- drawer={
- <XDSChatComposerDrawer 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={() => {}} />
- </XDSChatComposerDrawer>
- }
- />
- </XDSStack>
+ <XDSStack direction="vertical" gap={4} width={450}>
+ <XDSChatComposer
+ onSubmit={() => {}}
+ drawer={
+ <XDSChatComposerDrawer count={2}>
+ <XDSToken label="report.pdf" onRemove={() => {}} />
+ <XDSToken label="data.csv" onRemove={() => {}} />
+ </XDSChatComposerDrawer>
+ }
+ headerActions={
+ <>
+ <XDSButton
+ label="Mention"
+ variant="ghost"
+ size="sm"
+ icon={<XDSIcon icon={AtSymbolIcon} size="sm" />}
+ isIconOnly
+ onClick={() => {}}
+ />
+ <XDSButton
+ label="Attach"
+ variant="ghost"
+ size="sm"
+ icon={<XDSIcon icon={PaperClipIcon} size="sm" />}
+ isIconOnly
+ onClick={() => {}}
+ />
+ </>
+ }
+ />
</XDSStack>
);
}
diff --git a/packages/cli/templates/blocks/components/Chat/ChatMessageList.doc.mjs b/packages/cli/templates/blocks/components/Chat/ChatMessageList.doc.mjs
index 437f305cec..8cfa246101 100644
--- a/packages/cli/templates/blocks/components/Chat/ChatMessageList.doc.mjs
+++ b/packages/cli/templates/blocks/components/Chat/ChatMessageList.doc.mjs
@@ -4,6 +4,6 @@ export const doc = {
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,
+ aspectRatio: .85,
componentsUsed: ['Chat', 'Avatar', 'Markdown', 'Timestamp'],
};
diff --git a/packages/cli/templates/blocks/components/Chat/ChatMessageList.tsx b/packages/cli/templates/blocks/components/Chat/ChatMessageList.tsx
index 63237adb87..90b99ab358 100644
--- a/packages/cli/templates/blocks/components/Chat/ChatMessageList.tsx
+++ b/packages/cli/templates/blocks/components/Chat/ChatMessageList.tsx
@@ -6,76 +6,67 @@ import {
XDSChatMessageBubble,
XDSChatMessageMetadata,
XDSChatSystemMessage,
+ XDSChatTokenizedText,
} from '@xds/core/Chat';
import {XDSAvatar} from '@xds/core/Avatar';
import {XDSMarkdown} from '@xds/core/Markdown';
import {XDSTimestamp} from '@xds/core/Timestamp';
+import { XDSText } from '@xds/core/Text';
+
+const TOKENS = [{value: '@agent', label: '@agent', variant: 'red' as const}];
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:
+ <XDSChatMessageList density="spacious">
+ <XDSChatSystemMessage variant="divider">Today</XDSChatSystemMessage>
-- \`useState\` for local component state
-- \`useReducer\` for complex state logic
-- \`useContext\` for shared state across a subtree
+ <XDSChatMessage sender="user">
+ <XDSChatMessageBubble>
+ <XDSChatTokenizedText tokens={TOKENS}>
+ @agent How should I handle state management in a React app?
+ </XDSChatTokenizedText>
+ </XDSChatMessageBubble>
+ </XDSChatMessage>
-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="assistant"
+ avatar={<XDSAvatar name="Agent" size="small" />}>
+ <XDSChatMessageBubble variant="ghost">
+ <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>AI Agent 2.0</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>
+ <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>
+ <XDSChatSystemMessage>Agent is thinking…</XDSChatSystemMessage>
+ </XDSChatMessageList>
);
}
diff --git a/packages/cli/templates/blocks/components/Chat/ChatMixedContent.doc.mjs b/packages/cli/templates/blocks/components/Chat/ChatMixedContent.doc.mjs
index 1dac70bf75..eb7f1cae04 100644
--- a/packages/cli/templates/blocks/components/Chat/ChatMixedContent.doc.mjs
+++ b/packages/cli/templates/blocks/components/Chat/ChatMixedContent.doc.mjs
@@ -5,6 +5,6 @@ export const doc = {
description:
'AI chat with multiple bubble variants, code blocks, file tokens, system messages, and markdown.',
isReady: true,
- aspectRatio: 4 / 3,
+ aspectRatio: 3 / 4,
componentsUsed: ['Chat', 'Markdown', 'Token', 'Stack', 'CodeBlock'],
};
diff --git a/packages/cli/templates/blocks/components/Chat/ChatMixedContent.tsx b/packages/cli/templates/blocks/components/Chat/ChatMixedContent.tsx
index 288a077199..8d61c09d2a 100644
--- a/packages/cli/templates/blocks/components/Chat/ChatMixedContent.tsx
+++ b/packages/cli/templates/blocks/components/Chat/ChatMixedContent.tsx
@@ -25,14 +25,14 @@ export default function ChatMixedContent() {
<XDSChatMessageBubble>
Sure! Here's an overview of the component architecture.
</XDSChatMessageBubble>
- <XDSChatMessageBubble variant="ghost">
+ <XDSChatMessageBubble>
<XDSMarkdown density="compact">{`The system uses a **compound component** pattern with three layers:
1. **MessageList** — scrollable container with auto-scroll
2. **Message** — layout wrapper with sender context
3. **Bubble** — styled content container`}</XDSMarkdown>
</XDSChatMessageBubble>
- <XDSChatMessageBubble variant="ghost">
+ <XDSChatMessageBubble>
<XDSMarkdown density="compact">Here are the files:</XDSMarkdown>
<XDSHStack gap={2} wrap="wrap">
<XDSToken label="Button.tsx" />
@@ -56,26 +56,6 @@ export default function ChatMixedContent() {
<XDSChatMessageBubble>Open Button.tsx</XDSChatMessageBubble>
</XDSChatMessage>
- <XDSChatSystemMessage>Navi opened Button.tsx</XDSChatSystemMessage>
-
- <XDSChatMessage sender="assistant">
- <XDSChatMessageBubble variant="ghost">
- <XDSCodeBlock
- code={`export function XDSButton({ label, variant = 'primary' }) {
- return (
- <button className={styles[variant]}>
- {label}
- </button>
- );
-}`}
- language="tsx"
- />
- <XDSMarkdown density="compact">
- The Button reads variant from props and maps it to the matching
- style.
- </XDSMarkdown>
- </XDSChatMessageBubble>
- </XDSChatMessage>
</XDSChatMessageList>
</div>
);
diff --git a/packages/cli/templates/blocks/components/Chat/ChatShowcase.tsx b/packages/cli/templates/blocks/components/Chat/ChatShowcase.tsx
index c150559901..4f71c31e93 100644
--- a/packages/cli/templates/blocks/components/Chat/ChatShowcase.tsx
+++ b/packages/cli/templates/blocks/components/Chat/ChatShowcase.tsx
@@ -1,29 +1,43 @@
'use client';
import {
+ XDSChatLayout,
XDSChatMessageList,
XDSChatMessage,
XDSChatMessageBubble,
+ XDSChatComposer,
+ XDSChatTokenizedText,
} from '@xds/core/Chat';
-import {XDSMarkdown} from '@xds/core/Markdown';
+import {XDSAvatar} from '@xds/core/Avatar';
+import {XDSVStack} from '@xds/core/Stack';
+
+const TOKENS = [{value: '/review', label: '/review', variant: 'blue' as const}];
export default function ChatShowcase() {
return (
- <XDSChatMessageList>
- <XDSChatMessage sender="user">
- <XDSChatMessageBubble>
- 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**.`}</XDSMarkdown>
- </XDSChatMessage>
- </XDSChatMessageList>
+ <XDSVStack width={450}>
+ <XDSChatLayout
+ composer={
+ <XDSChatComposer
+ onSubmit={() => {}}
+ placeholder="Ask something..."
+ />
+ }>
+ <XDSChatMessageList>
+ <XDSChatMessage sender="user">
+ <XDSChatMessageBubble>
+ <XDSChatTokenizedText tokens={TOKENS}>
+ /review the changes in this file
+ </XDSChatTokenizedText>
+ </XDSChatMessageBubble>
+ </XDSChatMessage>
+ <XDSChatMessage sender="assistant">
+ <XDSChatMessageBubble variant="ghost">
+ Reading the file now...
+ </XDSChatMessageBubble>
+ </XDSChatMessage>
+ </XDSChatMessageList>
+ </XDSChatLayout>
+ </XDSVStack>
);
}
diff --git a/packages/cli/templates/blocks/components/Chat/ChatTokenizedText.tsx b/packages/cli/templates/blocks/components/Chat/ChatTokenizedText.tsx
index 381763f386..203d06704b 100644
--- a/packages/cli/templates/blocks/components/Chat/ChatTokenizedText.tsx
+++ b/packages/cli/templates/blocks/components/Chat/ChatTokenizedText.tsx
@@ -9,12 +9,6 @@ import {
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},
@@ -23,49 +17,14 @@ const mixedTokens = [
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>
+ <XDSChatMessageList>
+ <XDSChatMessage sender="system">
+ <XDSChatMessageBubble>
+ <XDSChatTokenizedText tokens={mixedTokens}>
+ @cindy filed #bug and #feat for the sprint
+ </XDSChatTokenizedText>
+ </XDSChatMessageBubble>
+ </XDSChatMessage>
+ </XDSChatMessageList>
);
}
diff --git a/packages/cli/templates/blocks/components/Chat/ChatToolCalls.doc.mjs b/packages/cli/templates/blocks/components/Chat/ChatToolCalls.doc.mjs
index f2077a0d24..7e2bb35edf 100644
--- a/packages/cli/templates/blocks/components/Chat/ChatToolCalls.doc.mjs
+++ b/packages/cli/templates/blocks/components/Chat/ChatToolCalls.doc.mjs
@@ -4,6 +4,6 @@ export const doc = {
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,
+ aspectRatio: 4 / 3,
componentsUsed: ['Chat', 'Layout', 'Text'],
};
diff --git a/packages/cli/templates/blocks/components/Chat/ChatToolCalls.tsx b/packages/cli/templates/blocks/components/Chat/ChatToolCalls.tsx
index ecdedb3b5a..bc2f84fa15 100644
--- a/packages/cli/templates/blocks/components/Chat/ChatToolCalls.tsx
+++ b/packages/cli/templates/blocks/components/Chat/ChatToolCalls.tsx
@@ -6,27 +6,13 @@ 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={6}>
<XDSStack direction="vertical" gap={1}>
<XDSText type="supporting" color="secondary">
Multiple calls with stats
</XDSText>
<XDSChatToolCalls
+ defaultIsExpanded
calls={[
{
name: 'bash',
@@ -53,9 +39,10 @@ export default function ChatToolCalls() {
</XDSStack>
<XDSStack direction="vertical" gap={1}>
<XDSText type="supporting" color="secondary">
- With error
+ Multiple calls with an error
</XDSText>
<XDSChatToolCalls
+ defaultIsExpanded
calls={[
{
name: 'bash',