Skip to content

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

TypeScript

updating gitignore and more stylex adjustments

Cindy Zhanga4185c66641b
diff --git a/.claude/commands/create-component.md b/.claude/commands/create-component.md
new file mode 100644
index 0000000000..26d2fbb503
--- /dev/null
+++ b/.claude/commands/create-component.md
@@ -0,0 +1,201 @@
+# Create XDS Component
+
+Create a new XDS component following established patterns.
+
+## Component Name
+
+$ARGUMENTS
+
+## Instructions
+
+Create a new component in `/packages/core/src/{ComponentName}/` with the following files:
+
+### 1. {ComponentName}.tsx (Main Component)
+
+Use this structure based on Button.tsx:
+
+```tsx
+/**
+ * @file {ComponentName}.tsx
+ * @input Uses React forwardRef, HTMLAttributes, ReactNode
+ * @output Exports {ComponentName} component, {ComponentName}Props, {ComponentName}Variant types
+ * @position Core implementation
+ *
+ * SYNC: When modified, update these files to stay in sync:
+ * - /packages/core/src/{ComponentName}/README.md
+ * - /packages/core/src/{ComponentName}/{ComponentName}.stories.tsx
+ * - /packages/core/src/{ComponentName}/index.ts
+ * - /apps/storybook/stories/{ComponentName}.stories.tsx
+ */
+
+import { forwardRef, type HTMLAttributes, type ReactNode } from 'react';
+import * as stylex from '@stylexjs/stylex';
+import {
+ colorTokens,
+ spacingTokens,
+ radiusTokens,
+ transitionTokens,
+ typographyTokens,
+} from '../theme/tokens.stylex';
+
+// Define styles first
+const styles = stylex.create({
+ base: {
+ // Base styles using tokens
+ },
+ disabled: {
+ cursor: 'not-allowed',
+ opacity: 0.5,
+ },
+});
+
+// Define variants - {ComponentName}Variant type will be derived from this
+const variants = stylex.create({
+ default: {
+ // Variant styles using tokens
+ },
+});
+
+// Derive variant type from the variants object
+export type {ComponentName}Variant = keyof typeof variants;
+
+export interface {ComponentName}Props extends HTMLAttributes<HTMLElement> {
+ variant?: {ComponentName}Variant;
+ children: ReactNode;
+}
+
+export const {ComponentName} = forwardRef<HTMLElement, {ComponentName}Props>(
+ ({ variant = 'default', children, ...props }, ref) => {
+ return (
+ <div
+ ref={ref}
+ {...stylex.props(styles.base, variants[variant])}
+ {...props}
+ >
+ {children}
+ </div>
+ );
+ }
+);
+
+{ComponentName}.displayName = '{ComponentName}';
+```
+
+### 2. index.ts (Exports)
+
+```tsx
+export { {ComponentName} } from './{ComponentName}';
+export type { {ComponentName}Props, {ComponentName}Variant } from './{ComponentName}';
+```
+
+### 3. README.md
+
+```markdown
+# /packages/core/src/{ComponentName}
+
+Brief description of the component.
+
+<!-- SYNC: When files in this directory change, update this document. -->
+
+## Features
+
+- **Variants**: List variants
+- Other features
+
+## Usage
+
+\`\`\`tsx
+import { {ComponentName} } from '@xds/core/{ComponentName}';
+
+<{ComponentName} variant="default">Content</{ComponentName}>
+\`\`\`
+
+## Props
+
+| Prop | Type | Default | Description |
+|------|------|---------|-------------|
+| `variant` | `'{variant1}' \| '{variant2}'` | `'default'` | Visual style variant |
+| `children` | `ReactNode` | — | Component content |
+
+## Files
+
+| File | Role | Purpose |
+|------|------|---------|
+| `index.ts` | Entry | Exports component and types |
+| `{ComponentName}.tsx` | Core | Component implementation |
+| `{ComponentName}.test.tsx` | Test | Unit tests |
+| `{ComponentName}.stories.tsx` | Docs | Storybook stories |
+
+## Implementation Notes
+
+- Variant type derived from `keyof typeof variants`
+```
+
+### 4. {ComponentName}.stories.tsx
+
+```tsx
+/**
+ * @file {ComponentName}.stories.tsx
+ */
+
+import type { Meta, StoryObj } from '@storybook/react';
+import { {ComponentName} } from './{ComponentName}';
+
+const meta = {
+ title: 'Components/{ComponentName}',
+ component: {ComponentName},
+ parameters: {
+ layout: 'centered',
+ },
+ tags: ['autodocs'],
+ argTypes: {
+ variant: {
+ control: 'select',
+ options: ['default'], // Add variants here
+ },
+ },
+} satisfies Meta<typeof {ComponentName}>;
+
+export default meta;
+type Story = StoryObj<typeof meta>;
+
+export const Default: Story = {
+ args: {
+ children: '{ComponentName} content',
+ variant: 'default',
+ },
+};
+```
+
+### 5. Update /packages/core/src/index.ts
+
+Add export for the new component:
+
+```tsx
+export * from './{ComponentName}';
+```
+
+## Key Patterns to Follow
+
+1. **Derive types from StyleX objects**: Use `keyof typeof variants` for variant types
+2. **Use tokens**: Import from `../theme/tokens.stylex` - never use hardcoded values
+3. **SYNC comments**: List all files that need updating when the component changes
+
+## Token Reference
+
+Available tokens from `tokens.stylex`:
+- `colorTokens`: accent, surface, textPrimary, hoverOverlay, pressedOverlay, focusOutline, negative, etc.
+- `spacingTokens`: space0, space0_5, space1, space2, space3, space4, space5, space6, space7
+- `radiusTokens`: rounded, container, element, content
+- `transitionTokens`: fast, normal
+- `typographyTokens`: fontFamilyBody, fontFamilyCode, fontFamilyHeading
+
+## Reference
+
+See `.context/explorations/component-reference.md` for the complete Button implementation with advanced patterns like loading states and hover overlays.
+
+## After Creation
+
+1. Run `pnpm --filter @xds/core build` to verify the build
+2. Create stories in `/apps/storybook/stories/{ComponentName}.stories.tsx`
+3. Add tests in `{ComponentName}.test.tsx`
diff --git a/.claude/commands/create-theme.md b/.claude/commands/create-theme.md
new file mode 100644
index 0000000000..dfc09c23b1
--- /dev/null
+++ b/.claude/commands/create-theme.md
@@ -0,0 +1,237 @@
+# Create XDS Theme
+
+Create a new XDS theme following established patterns.
+
+## Theme Name
+
+$ARGUMENTS
+
+## Instructions
+
+Create a new theme file at `/packages/core/src/theme/{themeName}Theme.stylex.ts`.
+
+### Theme File Template
+
+```tsx
+/**
+ * {ThemeName} Theme
+ *
+ * Description of this theme's visual style.
+ *
+ * Inspired by: [source if applicable]
+ */
+
+import * as stylex from '@stylexjs/stylex';
+import {
+ colorTokens,
+ elevationTokens,
+ spacingTokens,
+ radiusTokens,
+ transitionTokens,
+ typographyTokens,
+} from './tokens.stylex';
+import type { Theme } from './types';
+
+// =============================================================================
+// Color Theme
+// =============================================================================
+// Use light-dark() for automatic light/dark mode switching.
+// Format: 'light-dark(lightValue, darkValue)'
+
+const colorTheme = stylex.createTheme(colorTokens, {
+ // Core semantic
+ accent: 'light-dark(#YOUR_LIGHT, #YOUR_DARK)',
+ accentDeemphasized: 'light-dark(#YOUR_LIGHT33, #YOUR_DARK3F)',
+ accentText: 'light-dark(#YOUR_LIGHT, #YOUR_DARK)',
+ surface: 'light-dark(#FFFFFF, #1C1C1C)',
+ wash: 'light-dark(#F5F5F5, #121212)',
+ overlay: 'light-dark(#00000066, #00000099)',
+ hoverOverlay: 'light-dark(#0000000C, #FFFFFF0C)',
+ pressedOverlay: 'light-dark(#00000019, #FFFFFF19)',
+ focusOutline: 'light-dark(#YOUR_LIGHT, #YOUR_DARK)',
+ deemphasized: 'light-dark(#0000000C, #FFFFFF0C)',
+
+ // Text
+ textPrimary: 'light-dark(#171717, #FAFAFA)',
+ textSecondary: 'light-dark(#737373, #A3A3A3)',
+ textDisabled: 'light-dark(#A3A3A3, #525252)',
+ textLink: 'light-dark(#YOUR_LIGHT, #YOUR_DARK)',
+ textPlaceholder: 'light-dark(#737373, #A3A3A3)',
+
+ // Icon
+ iconPrimary: 'light-dark(#171717, #FAFAFA)',
+ iconSecondary: 'light-dark(#737373, #A3A3A3)',
+ iconTertiary: 'light-dark(#A3A3A3, #737373)',
+ iconDisabled: 'light-dark(#D4D4D4, #525252)',
+
+ // Surface variants
+ card: 'light-dark(#FFFFFF, #262626)',
+ popover: 'light-dark(#FFFFFF, #262626)',
+ navbar: 'light-dark(#FFFFFF, #171717)',
+
+ // Status/Sentiment
+ positive: 'light-dark(#22C55E, #22C55E)',
+ positiveDeemphasized: 'light-dark(#22C55E33, #22C55E3F)',
+ negative: 'light-dark(#EF4444, #EF4444)',
+ negativeDeemphasized: 'light-dark(#EF444433, #EF44443F)',
+ warning: 'light-dark(#F59E0B, #F59E0B)',
+ warningDeemphasized: 'light-dark(#F59E0B33, #F59E0B3F)',
+ educational: 'light-dark(#8B5CF6, #8B5CF6)',
+ educationalDeemphasized: 'light-dark(#8B5CF633, #8B5CF63F)',
+
+ // Divider
+ divider: 'light-dark(#E5E5E5, #404040)',
+ dividerHighContrast: 'light-dark(#A3A3A3, #737373)',
+ dividerEmphasized: 'light-dark(#D4D4D4, #525252)',
+
+ // Disabled/Effects
+ disabledOverlay: 'light-dark(#FFFFFF7F, #1717177F)',
+ glimmer: 'light-dark(#E5E5E5, #404040)',
+ glimmerHighContrast: 'light-dark(#D4D4D4, #525252)',
+ shadowElevation: 'light-dark(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.5))',
+
+ // Literal color sets (customize as needed)
+ blueBackground: 'light-dark(#3B82F633, #3B82F633)',
+ blueBorder: 'light-dark(#3B82F6, #60A5FA)',
+ blueIcon: 'light-dark(#3B82F6, #60A5FA)',
+ blueText: 'light-dark(#1D4ED8, #93C5FD)',
+
+ // ... add other color sets as needed
+});
+
+// =============================================================================
+// Elevation Theme
+// =============================================================================
+
+const elevationTheme = stylex.createTheme(elevationTokens, {
+ base: 'light-dark(0px 0px 1px rgba(0, 0, 0, 0.1), 0px 0px 1px rgba(0, 0, 0, 0.3))',
+ thumb: 'light-dark(0 1px 3px rgba(0, 0, 0, 0.2), 0 1px 3px rgba(0, 0, 0, 0.4))',
+ dialog: 'light-dark(0px 2px 2px rgba(0, 0, 0, 0.1), 0px 8px 24px rgba(0, 0, 0, 0.1), 0px 2px 2px rgba(0, 0, 0, 0.2), 0px 8px 24px rgba(0, 0, 0, 0.3))',
+ hover: 'light-dark(0px 1px 2px rgba(0, 0, 0, 0.1), 0px 2px 12px rgba(0, 0, 0, 0.1), 0px 1px 2px rgba(0, 0, 0, 0.2), 0px 2px 12px rgba(0, 0, 0, 0.2))',
+ menu: 'light-dark(0px 1px 1px rgba(0, 0, 0, 0.1), 0px 2px 8px rgba(0, 0, 0, 0.1), 0px 1px 1px rgba(0, 0, 0, 0.2), 0px 2px 8px rgba(0, 0, 0, 0.2))',
+});
+
+// =============================================================================
+// Spacing Theme (optional - inherit from default if unchanged)
+// =============================================================================
+
+const spacingTheme = stylex.createTheme(spacingTokens, {
+ space0: '0px',
+ space0_5: '2px',
+ space1: '4px',
+ space2: '8px',
+ space3: '12px',
+ space4: '16px',
+ space5: '20px',
+ space6: '24px',
+ space7: '32px',
+});
+
+// =============================================================================
+// Radius Theme (optional - customize for different feel)
+// =============================================================================
+
+const radiusTheme = stylex.createTheme(radiusTokens, {
+ rounded: '9999px',
+ container: '12px',
+ element: '8px',
+ content: '4px',
+});
+
+// =============================================================================
+// Transition Theme
+// =============================================================================
+
+const transitionTheme = stylex.createTheme(transitionTokens, {
+ fast: '0.15s ease',
+ normal: '0.2s ease',
+});
+
+// =============================================================================
+// Typography Theme
+// =============================================================================
+
+const typographyTheme = stylex.createTheme(typographyTokens, {
+ fontFamilyBody: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',
+ fontFamilyCode: '"SF Mono", Monaco, Consolas, monospace',
+ fontFamilyHeading: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',
+});
+
+// =============================================================================
+// Theme Export
+// =============================================================================
+
+export const {themeName}Theme: Theme = {
+ name: '{themeName}',
+ colorTheme,
+ elevationTheme,
+ spacingTheme,
+ radiusTheme,
+ transitionTheme,
+ typographyTheme,
+};
+```
+
+### Export from index.ts
+
+Add to `/packages/core/src/theme/index.ts`:
+
+```tsx
+export { {themeName}Theme } from './{themeName}Theme.stylex';
+```
+
+## Key Concepts
+
+### light-dark() Function
+
+All color values use CSS `light-dark()` for automatic mode switching:
+
+```tsx
+accent: 'light-dark(#0064E0, #2694FE)',
+// ^ light ^ dark
+```
+
+The Theme provider sets `color-scheme` to control which value is used.
+
+### Token Categories
+
+| Category | Purpose |
+|----------|---------|
+| `colorTokens` | All colors including semantic, text, icon, status, dividers |
+| `elevationTokens` | Box shadows for different elevation levels |
+| `spacingTokens` | Consistent spacing scale |
+| `radiusTokens` | Border radius for different contexts |
+| `transitionTokens` | Animation durations |
+| `typographyTokens` | Font families |
+
+### Minimal Theme (Extending Default)
+
+If you only need to change colors, you can spread the default theme:
+
+```tsx
+import { defaultTheme } from './defaultTheme.stylex';
+
+const colorTheme = stylex.createTheme(colorTokens, {
+ // Only override what you need
+ accent: 'light-dark(#YOUR_COLOR, #YOUR_DARK)',
+ // ...
+});
+
+export const myTheme: Theme = {
+ ...defaultTheme,
+ name: 'myTheme',
+ colorTheme,
+};
+```
+
+## Reference
+
+See existing themes for examples:
+- `/packages/core/src/theme/defaultTheme.stylex.ts` - Complete reference theme
+- `/packages/core/src/theme/neutralTheme.stylex.ts` - Grayscale theme with custom typography
+
+## After Creation
+
+1. Run `pnpm --filter @xds/core build` to verify the build
+2. Add theme to Storybook preview for testing: `/apps/storybook/.storybook/preview.tsx`
+3. Test in both light and dark modes
diff --git a/.context/explorations/component-reference.md b/.context/explorations/component-reference.md
new file mode 100644
index 0000000000..a3379b8689
--- /dev/null
+++ b/.context/explorations/component-reference.md
@@ -0,0 +1,249 @@
+# XDS Component Reference
+
+Patterns and techniques for building XDS components with StyleX.
+
+## Component Architecture
+
+### File Structure
+
+```
+/packages/core/src/{ComponentName}/
+├── {ComponentName}.tsx # Main component implementation
+├── index.ts # Exports
+├── README.md # Documentation
+├── {ComponentName}.stories.tsx # Storybook stories
+└── {ComponentName}.test.tsx # Tests
+```
+
+### Basic Component Template
+
+```tsx
+import { forwardRef, type HTMLAttributes, type ReactNode } from 'react';
+import * as stylex from '@stylexjs/stylex';
+import { colorTokens, spacingTokens } from '../theme/tokens.stylex';
+
+const styles = stylex.create({
+ base: {
+ // Base styles using tokens
+ },
+});
+
+const variants = stylex.create({
+ default: { /* ... */ },
+ // Add more variants as needed
+});
+
+// Derive type from StyleX object
+export type ComponentVariant = keyof typeof variants;
+
+export interface ComponentProps extends HTMLAttributes<HTMLElement> {
+ variant?: ComponentVariant;
+ children: ReactNode;
+}
+
+export const Component = forwardRef<HTMLElement, ComponentProps>(
+ ({ variant = 'default', children, ...props }, ref) => {
+ return (
+ <div
+ ref={ref}
+ {...stylex.props(styles.base, variants[variant])}
+ {...props}
+ >
+ {children}
+ </div>
+ );
+ }
+);
+
+Component.displayName = 'Component';
+```
+
+## Type Derivation Pattern
+
+Derive variant types from StyleX objects to keep types in sync with styles:
+
+```tsx
+const variants = stylex.create({
+ primary: { /* ... */ },
+ secondary: { /* ... */ },
+ ghost: { /* ... */ },
+});
+
+export type ButtonVariant = keyof typeof variants;
+// Results in: 'primary' | 'secondary' | 'ghost'
+```
+
+When you add or remove a variant from the StyleX object, the type automatically updates.
+
+## StyleX Patterns
+
+### Using Tokens
+
+Always use tokens from `tokens.stylex` instead of hardcoded values:
+
+```tsx
+import {
+ colorTokens,
+ spacingTokens,
+ radiusTokens,
+ transitionTokens,
+ typographyTokens,
+} from '../theme/tokens.stylex';
+
+const styles = stylex.create({
+ base: {
+ backgroundColor: colorTokens.surface,
+ padding: spacingTokens.space3,
+ borderRadius: radiusTokens.element,
+ fontFamily: typographyTokens.fontFamilyBody,
+ transitionDuration: transitionTokens.fast,
+ },
+});
+```
+
+### Conditional Styles
+
+Apply styles conditionally using `stylex.props`:
+
+```tsx
+{...stylex.props(
+ styles.base,
+ variants[variant],
+ isDisabled && styles.disabled,
+ isLoading && styles.loading
+)}
+```
+
+### Pseudo-selectors
+
+StyleX supports common pseudo-selectors:
+
+```tsx
+const styles = stylex.create({
+ interactive: {
+ ':hover': {
+ backgroundColor: colorTokens.hoverOverlay,
+ },
+ ':active': {
+ backgroundColor: colorTokens.pressedOverlay,
+ },
+ ':focus-visible': {
+ outline: `2px solid ${colorTokens.focusOutline}`,
+ outlineOffset: '3px',
+ },
+ },
+});
+```
+
+### Animations
+
+Use `stylex.keyframes` for animations:
+
+```tsx
+const styles = stylex.create({
+ spinner: {
+ animationName: stylex.keyframes({
+ to: { transform: 'rotate(360deg)' },
+ }),
+ animationDuration: '0.6s',
+ animationTimingFunction: 'linear',
+ animationIterationCount: 'infinite',
+ },
+});
+```
+
+## Advanced Patterns
+
+### Overlay Hover/Active States
+
+For interactive elements where you want hover/active colors to layer on top of the base background (not replace it), use `backgroundImage`:
+
+```tsx
+const variants = stylex.create({
+ primary: {
+ backgroundColor: colorTokens.accent,
+ ':hover': {
+ backgroundImage: `linear-gradient(${colorTokens.hoverOverlay}, ${colorTokens.hoverOverlay})`,
+ },
+ ':active': {
+ backgroundImage: `linear-gradient(${colorTokens.pressedOverlay}, ${colorTokens.pressedOverlay})`,
+ },
+ },
+});
+```
+
+This works because `background-image` renders on top of `background-color`.
+
+### Variant-Specific Focus Colors
+
+Some components need different focus outline colors per variant:
+
+```tsx
+const variants = stylex.create({
+ primary: {
+ ':focus-visible': {
+ outline: `2px solid ${colorTokens.focusOutline}`,
+ outlineOffset: '3px',
+ },
+ },
+ destructive: {
+ ':focus-visible': {
+ outline: `2px solid ${colorTokens.negative}`,
+ outlineOffset: '3px',
+ },
+ },
+});
+```
+
+### Loading States
+
+Pattern for components with loading indicators:
+
+```tsx
+const loadingStyles = stylex.create({
+ loading: {
+ position: 'relative',
+ color: 'transparent', // Hide text while loading
+ },
+ spinner: {
+ position: 'absolute',
+ // Spinner styles...
+ },
+});
+
+// In component:
+{...stylex.props(
+ styles.base,
+ loading && loadingStyles.loading
+)}
+{loading && <span {...stylex.props(loadingStyles.spinner)} />}
+```
+
+## Known StyleX Limitations
+
+See `.context/explorations/stylex-patterns.md` for detailed notes:
+
+1. **No runtime `stylex.create()`** - All styles must be compiled at build time
+2. **Combined pseudo-selectors don't work** - `:hover::after` is not supported
+3. **Use `backgroundImage` for overlays** - Instead of `::after` pseudo-elements
+
+## Token Reference
+
+Available tokens from `tokens.stylex`:
+
+| Category | Tokens |
+|----------|--------|
+| `colorTokens` | accent, surface, textPrimary, textSecondary, hoverOverlay, pressedOverlay, focusOutline, negative, positive, etc. |
+| `spacingTokens` | space0, space0_5, space1, space2, space3, space4, space5, space6, space7 |
+| `radiusTokens` | rounded, container, element, content |
+| `transitionTokens` | fast, normal |
+| `typographyTokens` | fontFamilyBody, fontFamilyCode, fontFamilyHeading |
+
+## Example: Button Component
+
+See `/packages/core/src/Button/Button.tsx` for a complete implementation demonstrating:
+- Multiple variants (primary, secondary, ghost, destructive)
+- Loading state with spinner
+- Overlay hover/active states
+- Variant-specific focus colors
+- Type derivation from StyleX object
diff --git a/packages/core/src/Button/Button.stories.tsx b/packages/core/src/Button/Button.stories.tsx
index 1105908d7c..f9d0efa3f0 100644
--- a/packages/core/src/Button/Button.stories.tsx
+++ b/packages/core/src/Button/Button.stories.tsx
@@ -20,11 +20,7 @@ const meta = {
argTypes: {
variant: {
control: 'select',
- options: ['primary', 'secondary', 'ghost'],
- },
- size: {
- control: 'select',
- options: ['sm', 'md', 'lg'],
+ options: ['primary', 'secondary', 'ghost', 'destructive'],
},
loading: {
control: 'boolean',
@@ -59,23 +55,16 @@ export const Ghost: Story = {
},
};
-export const Small: Story = {
- args: {
- children: 'Small Button',
- size: 'sm',
- },
-};
-
-export const Large: Story = {
+export const Destructive: Story = {
args: {
- children: 'Large Button',
- size: 'lg',
+ children: 'Delete',
+ variant: 'destructive',
},
};
export const Loading: Story = {
args: {
- children: 'Submit',
+ children: 'Saving...',
loading: true,
},
};
diff --git a/packages/core/src/Button/Button.tsx b/packages/core/src/Button/Button.tsx
index bf1aff8a3a..41332a600b 100644
--- a/packages/core/src/Button/Button.tsx
+++ b/packages/core/src/Button/Button.tsx
@@ -4,7 +4,11 @@
* @output Exports Button component, ButtonProps, ButtonVariant types
* @position Core implementation; consumed by index.ts, tested by Button.test.tsx
*
- * SYNC: When modified, update this header and /packages/core/src/Button/README.md
+ * SYNC: When modified, update these files to stay in sync:
+ * - /packages/core/src/Button/README.md (props table, features, implementation notes)
+ * - /packages/core/src/Button/Button.stories.tsx (argTypes, stories for new variants)
+ * - /packages/core/src/Button/index.ts (exports if types change)
+ * - /apps/storybook/stories/Button.stories.tsx (storybook app stories)
*/
import { forwardRef, type ButtonHTMLAttributes, type ReactNode } from 'react';
diff --git a/packages/core/src/Button/README.md b/packages/core/src/Button/README.md
index fcb707493f..00eea7aab8 100644
--- a/packages/core/src/Button/README.md
+++ b/packages/core/src/Button/README.md
@@ -1,9 +1,42 @@
# /packages/core/src/Button
-Button component with multiple variants, sizes, and loading state support.
+Button component with multiple variants and loading state support.
<!-- SYNC: When files in this directory change, update this document. -->
+## Features
+
+- **Variants**: `primary`, `secondary`, `ghost`, `destructive`
+- **Loading state**: Shows spinner, disables interaction
+- **Focus visible**: Accessible focus outline with variant-specific colors
+- **Hover/active states**: Uses overlay colors via `backgroundImage` for consistent layering
+
+## Usage
+
+```tsx
+import { Button } from '@xds/core/Button';
+
+// Basic usage
+<Button variant="primary">Click me</Button>
+
+// With loading state
+<Button variant="primary" loading>Saving...</Button>
+
+// Destructive action
+<Button variant="destructive">Delete</Button>
+```
+
+## Props
+
+| Prop | Type | Default | Description |
+|------|------|---------|-------------|
+| `variant` | `'primary' \| 'secondary' \| 'ghost' \| 'destructive'` | `'primary'` | Visual style variant |
+| `loading` | `boolean` | `false` | Shows loading spinner |
+| `disabled` | `boolean` | `false` | Disables the button |
+| `children` | `ReactNode` | — | Button content |
+
+## Files
+
| File | Role | Purpose |
|------|------|---------|
| `index.ts` | Entry | Exports Button component and types |
@@ -11,3 +44,8 @@ Button component with multiple variants, sizes, and loading state support.
| `Button.test.tsx` | Test | Unit tests for Button component |
| `Button.stories.tsx` | Docs | Storybook stories for visual documentation |
+## Implementation Notes
+
+- `ButtonVariant` type is derived from the `variants` StyleX object using `keyof typeof variants`
+- Hover/active states use `backgroundImage` with `linear-gradient` to layer overlay colors on top of the base background
+- Destructive variant uses `colorTokens.negative` for its focus outline color