Skip to content

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

TypeScript

fix(Chat,CodeBlock): hover guard, icon registry, escape hatch props (#2554)

Cindy Zhang18b317f4ee31
diff --git a/apps/sandbox/.claude/CLAUDE.md b/apps/sandbox/.claude/CLAUDE.md
new file mode 100644
index 0000000000..de01df92fb
--- /dev/null
+++ b/apps/sandbox/.claude/CLAUDE.md
@@ -0,0 +1,46 @@
+# CLAUDE.md
+
+Project-specific guidance for AI coding agents.
+
+<!-- XDS:START -->
+
+XDS v0.0.14 — 170 components
+
+Before writing any UI code:
+
+1. `pnpm exec xds template --list` — find a related page pattern
+2. `pnpm exec xds template <name> --skeleton` — study layout structure (gap, padding, nesting)
+3. `pnpm exec xds component <Name>` — read props + examples for EVERY component you use
+
+Templates are reference code — read them for composition patterns, not just scaffolding.
+Full pages → dashboard (uses XDSAppShell). Forms → contact-form. Tables → data-table. Settings → settings-sidebar.
+
+No <div> anywhere — not for layout, not for wrappers, not for spacing. Use components.
+Full-page shells → XDSAppShell (not XDSLayout). Sidebar nav → XDSSideNav (not XDSList).
+No style={{}} — use the xstyle prop on components for custom styling.
+If a component prop does what you need, use it — never replicate with CSS/stylex.
+No magic values — run `pnpm exec xds docs tokens` for spacing/color/radius.
+To change accent/brand colors: `pnpm exec xds theme` — never override --xds-color-\* in :root.
+
+pnpm exec xds component --list 170 components by category
+pnpm exec xds component <Name> props, types, examples
+pnpm exec xds docs color Semantic color tokens for surfaces, text, icons...
+pnpm exec xds docs elevation Shadow tokens for visual elevation and inset st...
+pnpm exec xds docs icons Semantic icon names available in the design sys...
+pnpm exec xds docs illustrations Illustration guidelines for empty states, onboa...
+pnpm exec xds docs migration How to migrate an existing Tailwind, shadcn, or...
+pnpm exec xds docs motion Duration and easing tokens for animations and t...
+pnpm exec xds docs principles Core design principles and rules for building w...
+pnpm exec xds docs shape Border radius tokens for consistent component r...
+pnpm exec xds docs spacing Spacing scale tokens for padding, gap, and marg...
+pnpm exec xds docs styling How to customize component appearance: xstyle p...
+pnpm exec xds docs theme XDSTheme provider, custom themes, theme build f...
+pnpm exec xds docs tokens tokens
+pnpm exec xds docs typography Font families, geometric type scale, weight, li...
+pnpm exec xds template --list page recipes with component lists
+pnpm exec xds template <name> [path] scaffold from template
+pnpm exec xds swizzle <Name> eject source (--gap to report why)
+pnpm exec xds upgrade --apply codemods after version bump
+after @xds/core bump, always run pnpm exec xds upgrade --apply
+
+<!-- XDS:END -->
diff --git a/packages/core/src/Chat/XDSChatDictationButton.tsx b/packages/core/src/Chat/XDSChatDictationButton.tsx
index f29b7fe89b..5fc1cb42fa 100644
--- a/packages/core/src/Chat/XDSChatDictationButton.tsx
+++ b/packages/core/src/Chat/XDSChatDictationButton.tsx
@@ -103,6 +103,8 @@ export function XDSChatDictationButton({
isHiddenWhenUnsupported = true,
label,
xstyle,
+ className,
+ style,
}: XDSChatDictationButtonProps) {
if (isHiddenWhenUnsupported && !dictation.isSupported) {
return null;
@@ -126,7 +128,9 @@ export function XDSChatDictationButton({
const {barWidth, barGap, barMaxHeight} = SIZE_CONFIG[size];
return (
- <span ref={ref} {...stylex.props(styles.wrapper, xstyle)}>
+ <span
+ ref={ref}
+ {...mergeProps(stylex.props(styles.wrapper, xstyle), className, style)}>
{isListening && (
<span
aria-hidden
diff --git a/packages/core/src/Chat/XDSChatLayoutScrollButton.tsx b/packages/core/src/Chat/XDSChatLayoutScrollButton.tsx
index 9a7320bdb3..146ee33a3f 100644
--- a/packages/core/src/Chat/XDSChatLayoutScrollButton.tsx
+++ b/packages/core/src/Chat/XDSChatLayoutScrollButton.tsx
@@ -29,6 +29,7 @@ import {
import {XDSIcon} from '../Icon';
import {XDSButton} from '../Button';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {mergeProps} from '../utils';
// =============================================================================
// Types
@@ -108,9 +109,14 @@ export function XDSChatLayoutScrollButton({
isVisible,
label,
onClick,
+ xstyle,
+ className,
+ style,
}: XDSChatLayoutScrollButtonProps) {
return (
- <div ref={ref} {...stylex.props(styles.wrapper)}>
+ <div
+ ref={ref}
+ {...mergeProps(stylex.props(styles.wrapper, xstyle), className, style)}>
<div
{...stylex.props(
styles.container,
diff --git a/packages/core/src/Chat/XDSChatMessageMetadata.tsx b/packages/core/src/Chat/XDSChatMessageMetadata.tsx
index 66d80880ff..c343d1fa72 100644
--- a/packages/core/src/Chat/XDSChatMessageMetadata.tsx
+++ b/packages/core/src/Chat/XDSChatMessageMetadata.tsx
@@ -114,6 +114,9 @@ export function XDSChatMessageMetadata({
timestamp,
footer,
status,
+ xstyle,
+ className,
+ style,
}: XDSChatMessageMetadataProps) {
const msgContext = useXDSChatMessageContext();
const sender = msgContext?.sender ?? 'assistant';
@@ -134,7 +137,10 @@ export function XDSChatMessageMetadata({
stylex.props(
styles.meta,
sender === 'user' ? styles.metaUser : styles.metaAssistant,
+ xstyle,
),
+ className,
+ style,
)}>
{timestamp != null && <span>{timestamp}</span>}
{timestamp != null && (footer != null || statusConfig != null) && (
diff --git a/packages/core/src/Chat/XDSChatToolCalls.tsx b/packages/core/src/Chat/XDSChatToolCalls.tsx
index 8a88e8a0dc..e260ddfcdf 100644
--- a/packages/core/src/Chat/XDSChatToolCalls.tsx
+++ b/packages/core/src/Chat/XDSChatToolCalls.tsx
@@ -171,8 +171,10 @@ const styles = stylex.create({
borderRadius: radiusVars['--radius-element'],
paddingInline: spacingVars['--spacing-1'],
marginInline: `calc(-1 * ${spacingVars['--spacing-1']})`,
- ':hover': {
- backgroundColor: colorVars['--color-overlay-hover'],
+ '@media (hover: hover)': {
+ ':hover': {
+ backgroundColor: colorVars['--color-overlay-hover'],
+ },
},
},
callRowToggle: {
diff --git a/packages/core/src/CodeBlock/XDSCodeBlock.tsx b/packages/core/src/CodeBlock/XDSCodeBlock.tsx
index d8ada65d43..6a3306b42d 100644
--- a/packages/core/src/CodeBlock/XDSCodeBlock.tsx
+++ b/packages/core/src/CodeBlock/XDSCodeBlock.tsx
@@ -669,31 +669,8 @@ export function XDSCodeBlock({
? {maxHeight: typeof maxHeight === 'number' ? `${maxHeight}px` : maxHeight}
: undefined;
- const copyIcon = copied ? (
- <svg
- width="1em"
- height="1em"
- viewBox="0 0 24 24"
- fill="none"
- stroke="currentColor"
- strokeWidth={1.5}
- strokeLinecap="round"
- strokeLinejoin="round">
- <path d="M5 13l4 4L19 7" />
- </svg>
- ) : (
- <svg
- width="1em"
- height="1em"
- viewBox="0 0 24 24"
- fill="none"
- stroke="currentColor"
- strokeWidth={1.5}
- strokeLinecap="round"
- strokeLinejoin="round">
- <path d="M8 4v12a2 2 0 002 2h8a2 2 0 002-2V7.242a2 2 0 00-.602-1.43L16.083 2.57A2 2 0 0014.685 2H10a2 2 0 00-2 2z" />
- <path d="M16 18v2a2 2 0 01-2 2H6a2 2 0 01-2-2V9a2 2 0 012-2h2" />
- </svg>
+ const copyIcon = (
+ <XDSIcon icon={copied ? 'check' : 'copy'} size="sm" color="inherit" />
);
const copyButtonEl = hasCopyButton ? (