An open source design system that's fully customizable and agent ready
TypeScript
themes visible in storybook, example of custom theme included
Cindy Zhangb11321b641c3
diff --git a/.context/explorations/component-swizzling.md b/.context/explorations/component-swizzling.mdnew file mode 100644index 0000000000..f1745cd0d7--- /dev/null+++ b/.context/explorations/component-swizzling.md@@ -0,0 +1,101 @@+# Component Swizzling++Exploration of how customized components could be distributed alongside themes.++## Problem++Themes in XDS control design tokens (colors, spacing, typography, etc.), but some design systems need deeper customization at the component level. For example:++- **shadcn buttons** handle variants differently than XDS buttons+- A brand might want different hover behaviors, animations, or structural changes+- Token-level theming can't always achieve the desired visual output++## Swizzling Concept++"Swizzling" (term from Docusaurus) means ejecting/overriding a component to customize it. The question: how could swizzled components be distributed as easily as themes?++## Current State++```+Theme Distribution:+├── defaultTheme.stylex.ts (complete, copyable template)+├── neutralTheme.stylex.ts (demonstrates customization)+└── Consumer creates custom themes by copying/modifying+```++Themes are self-contained files that can be copied and modified. Could components follow a similar pattern?++## Possible Approaches++### 1. Component Recipes (like shadcn)+Provide component source files that consumers copy into their project:+```+npx xds add button+→ copies Button.tsx into your project+```++Pros: Full control, no abstraction leak+Cons: No automatic updates, divergence over time++### 2. Component Variants as Theme Extensions+Extend the theme object to include component-specific overrides:+```tsx+const myTheme = {+ ...defaultTheme,+ components: {+ Button: {+ variants: {+ primary: { /* custom styles */ },+ },+ },+ },+};+```++Pros: Stays within theme system+Cons: Limited to style overrides, can't change structure++### 3. Component Slots/Composition+Design components with explicit customization points:+```tsx+<Button+ renderIcon={(props) => <CustomIcon {...props} />}+ styles={{ hover: customHoverStyles }}+/>+```++Pros: Controlled flexibility+Cons: API complexity, can't anticipate all needs++### 4. Component Registry+Allow registering custom component implementations:+```tsx+import { registerComponent } from '@xds/core';+import { MyButton } from './MyButton';++registerComponent('Button', MyButton);+```++Pros: Clean swap mechanism+Cons: Runtime overhead, type safety challenges++## Questions to Explore++1. What level of customization do consumers actually need?+2. Should swizzled components be "blessed" variants or fully custom?+3. How do we handle breaking changes in base components?+4. Can we version component APIs separately from token APIs?++## Relationship to Themes++Ideally, swizzled components would:+- Be as portable as theme files+- Work with any theme (not coupled to specific tokens)+- Be discoverable/shareable across teams+- Have clear upgrade paths++## Next Steps++- Survey how shadcn, Radix, and other systems handle this+- Identify which XDS components are most likely to need swizzling+- Prototype one approach with Button componentdiff --git a/.context/explorations/stylex-patterns.md b/.context/explorations/stylex-patterns.mdnew file mode 100644index 0000000000..3299337e55--- /dev/null+++ b/.context/explorations/stylex-patterns.md@@ -0,0 +1,96 @@+# StyleX Patterns and Challenges++Notes on StyleX usage patterns discovered while building XDS components.++## Compile-Time Requirement++StyleX requires all styles to be compiled at build time via the Babel plugin. You cannot use `stylex.create()` at runtime (e.g., in Storybook's preview.tsx).++**Solution**: Pre-compile styles in the component library and export them, or use plain CSS/inline styles in non-compiled contexts.++## Combined Pseudo-Selectors++StyleX has limited support for combined pseudo-selectors like `:hover::after` or `:active::after`.++**Problem**: Tried using `::after` pseudo-element for hover/active overlay effects:+```tsx+const styles = stylex.create({+ base: {+ '::after': {+ content: '""',+ position: 'absolute',+ inset: 0,+ backgroundColor: 'transparent',+ },+ ':hover::after': {+ backgroundColor: colorTokens.hoverOverlay,+ },+ ':active::after': {+ backgroundColor: colorTokens.pressedOverlay,+ },+ },+});+```++This approach did not work as expected.++**Solution**: Use `backgroundImage` with `linear-gradient` to layer colors:+```tsx+const variants = stylex.create({+ primary: {+ backgroundColor: colorTokens.accent,+ color: 'white',+ ':hover': {+ backgroundImage: `linear-gradient(${colorTokens.hoverOverlay}, ${colorTokens.hoverOverlay})`,+ },+ ':active': {+ backgroundImage: `linear-gradient(${colorTokens.pressedOverlay}, ${colorTokens.pressedOverlay})`,+ },+ },+});+```++Since `background-image` renders on top of `background-color`, the semi-transparent overlay blends naturally with the base color.++## Theme Variables with light-dark()++StyleX works well with CSS `light-dark()` function for automatic dark mode support:+```tsx+const colorTheme = stylex.createTheme(colorTokens, {+ accent: 'light-dark(#0064E0, #2694FE)',+ surface: 'light-dark(#FFFFFF, #1C1C1C)',+});+```++The Theme provider sets `color-scheme` property to control which value is used:+```tsx+const wrapperStyles = stylex.create({+ light: { colorScheme: 'light' },+ dark: { colorScheme: 'dark' },+ system: { colorScheme: 'light dark' },+});+```++## Public CSS Variables++To expose StyleX tokens as predictable CSS variables for non-StyleX consumers:+```tsx+export const publicVariables = stylex.create({+ all: {+ '--xds-accent': colorTokens.accent,+ '--xds-surface': colorTokens.surface,+ // ... map all tokens+ },+});+```++Apply in Theme provider:+```tsx+const stylexProps = stylex.props(+ publicVariables.all,+ theme.colorTheme,+ // ... other themes+);+```++Consumers can then use `var(--xds-surface)` in plain CSS or inline styles.diff --git a/.context/proposals/xds-architecture.md b/.context/proposals/xds-architecture.mdindex ed413bac43..736ab103ff 100644--- a/.context/proposals/xds-architecture.md+++ b/.context/proposals/xds-architecture.md@@ -1171,6 +1171,8 @@ This provides tw-classed ergonomics without exposed CSS classes.- `ai-trajectory-predictions.md` — Why constraints matter long-term- `required-props-pattern.md` — Explicit APIs for AI- `distribution-methods.md` — How themes will be distributed+- `stylex-patterns.md` — StyleX usage patterns, challenges, and workarounds (e.g., `backgroundImage` for overlay effects)+- `component-swizzling.md` — How customized components could be distributed alongside themes---diff --git a/apps/storybook/.storybook/preview.tsx b/apps/storybook/.storybook/preview.tsxindex 8cff9f4f34..b83be82f96 100644--- a/apps/storybook/.storybook/preview.tsx+++ b/apps/storybook/.storybook/preview.tsx@@ -1,13 +1,13 @@import type { Preview, Decorator } from '@storybook/react';import * as React from 'react';-import { Theme, defaultTheme, shadcnTheme } from '@xds/core';+import { Theme, defaultTheme, neutralTheme } from '@xds/core';/*** Map of available themes*/const themes = {default: defaultTheme,- shadcn: shadcnTheme,+ neutral: neutralTheme,};/**@@ -23,7 +23,14 @@ const withXDSTheme: Decorator = (Story, context) => {return (<Theme theme={theme} mode={mode}>- <Story />+ <div+ style={{+ backgroundColor: 'var(--xds-surface)',+ padding: 16,+ }}+ >+ <Story />+ </div></Theme>);};@@ -39,6 +46,7 @@ const preview: Preview = {backgrounds: {disable: true, // Disable backgrounds addon, use theme instead},+ layout: 'fullscreen',},globalTypes: {xdsTheme: {@@ -48,7 +56,7 @@ const preview: Preview = {icon: 'paintbrush',items: [{ value: 'default', title: 'Default', icon: 'circlehollow' },- { value: 'shadcn', title: 'Shadcn', icon: 'circle' },+ { value: 'neutral', title: 'Neutral', icon: 'circle' },],dynamicTitle: true,},diff --git a/apps/storybook/stories/Button.stories.tsx b/apps/storybook/stories/Button.stories.tsxindex 8f21b2c859..f44b124e06 100644--- a/apps/storybook/stories/Button.stories.tsx+++ b/apps/storybook/stories/Button.stories.tsx@@ -8,14 +8,9 @@ const meta: Meta<typeof Button> = {argTypes: {variant: {control: 'select',- options: ['primary', 'secondary', 'ghost'],+ options: ['primary', 'secondary', 'ghost', 'destructive'],description: 'Visual style variant',},- size: {- control: 'select',- options: ['sm', 'md', 'lg'],- description: 'Button size',- },loading: {control: 'boolean',description: 'Loading state',@@ -33,7 +28,6 @@ type Story = StoryObj<typeof Button>;export const Primary: Story = {args: {variant: 'primary',- size: 'md',children: 'Primary Button',},};@@ -41,7 +35,6 @@ export const Primary: Story = {export const Secondary: Story = {args: {variant: 'secondary',- size: 'md',children: 'Secondary Button',},};@@ -49,15 +42,20 @@ export const Secondary: Story = {export const Ghost: Story = {args: {variant: 'ghost',- size: 'md',children: 'Ghost Button',},};+export const Destructive: Story = {+ args: {+ variant: 'destructive',+ children: 'Delete',+ },+};+export const Loading: Story = {args: {variant: 'primary',- size: 'md',loading: true,children: 'Loading...',},@@ -66,22 +64,11 @@ export const Loading: Story = {export const Disabled: Story = {args: {variant: 'primary',- size: 'md',disabled: true,children: 'Disabled',},};-export const Sizes: Story = {- render: () => (- <div style={{ display: 'flex', gap: '12px', alignItems: 'center' }}>- <Button size="sm">Small</Button>- <Button size="md">Medium</Button>- <Button size="lg">Large</Button>- </div>- ),-};-export const AllVariants: Story = {render: () => (<div style={{ display: 'flex', flexDirection: 'column', gap: '12px', maxWidth: '600px' }}>@@ -89,16 +76,19 @@ export const AllVariants: Story = {<Button variant="primary">Primary</Button><Button variant="secondary">Secondary</Button><Button variant="ghost">Ghost</Button>+ <Button variant="destructive">Destructive</Button></div><div style={{ display: 'flex', gap: '12px' }}><Button variant="primary" loading>Loading...</Button><Button variant="secondary" loading>Loading...</Button><Button variant="ghost" loading>Loading...</Button>+ <Button variant="destructive" loading>Loading...</Button></div><div style={{ display: 'flex', gap: '12px' }}><Button variant="primary" disabled>Disabled</Button><Button variant="secondary" disabled>Disabled</Button><Button variant="ghost" disabled>Disabled</Button>+ <Button variant="destructive" disabled>Disabled</Button></div></div>),diff --git a/packages/core/src/Button/Button.tsx b/packages/core/src/Button/Button.tsxindex 41010a8cea..bf1aff8a3a 100644--- a/packages/core/src/Button/Button.tsx+++ b/packages/core/src/Button/Button.tsx@@ -1,7 +1,7 @@/*** @file Button.tsx* @input Uses React forwardRef, ButtonHTMLAttributes, ReactNode- * @output Exports Button component, ButtonProps, ButtonVariant, ButtonSize types+ * @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@@ -17,118 +17,120 @@ import {typographyTokens,} from '../theme/tokens.stylex';-export type ButtonVariant = 'primary' | 'secondary' | 'ghost';-export type ButtonSize = 'sm' | 'md' | 'lg';--export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {- /**- * The visual style variant of the button.- * @default 'primary'- */- variant?: ButtonVariant;- /**- * The size of the button.- * @default 'md'- */- size?: ButtonSize;- /**- * Whether the button is in a loading state.- * @default false- */- loading?: boolean;- /**- * Content to render inside the button.- */- children: ReactNode;-}-/*** Base button styles*/const styles = stylex.create({base: {+ position: 'relative',display: 'inline-flex',alignItems: 'center',justifyContent: 'center',gap: spacingTokens.space2,+ paddingBlock: spacingTokens.space2,+ paddingInline: spacingTokens.space3,borderWidth: 0,borderStyle: 'none',borderRadius: radiusTokens.element,fontFamily: typographyTokens.fontFamilyBody,+ fontSize: '0.875rem',+ lineHeight: 1.429,fontWeight: 500,cursor: 'pointer',- transitionProperty: 'background-color, box-shadow',+ transitionProperty: 'background-image',transitionDuration: transitionTokens.fast,},disabled: {cursor: 'not-allowed',opacity: 0.5,},- focusVisible: {- outline: `2px solid ${colorTokens.focusOutline}`,- outlineOffset: '2px',- },});/**- * Variant styles+ * Variant styles using backgroundImage for layered colors+ * Overlay is stacked on top of base color using multiple linear-gradients+ * Focus outline color matches variant (destructive uses negative color)*/const variants = stylex.create({primary: {backgroundColor: colorTokens.accent,color: 'white',- },- primaryHover: {- filter: 'brightness(1.1)',- },- primaryActive: {- filter: 'brightness(0.95)',+ ':hover': {+ backgroundImage: `linear-gradient(${colorTokens.hoverOverlay}, ${colorTokens.hoverOverlay})`,+ },+ ':active': {+ backgroundImage: `linear-gradient(${colorTokens.pressedOverlay}, ${colorTokens.pressedOverlay})`,+ },+ ':focus-visible': {+ outline: `2px solid ${colorTokens.focusOutline}`,+ outlineOffset: '3px',+ },},secondary: {backgroundColor: colorTokens.deemphasized,color: colorTokens.textPrimary,- },- secondaryHover: {- backgroundColor: colorTokens.hoverOverlay,- },- secondaryActive: {- backgroundColor: colorTokens.pressedOverlay,+ ':hover': {+ backgroundImage: `linear-gradient(${colorTokens.hoverOverlay}, ${colorTokens.hoverOverlay})`,+ },+ ':active': {+ backgroundImage: `linear-gradient(${colorTokens.pressedOverlay}, ${colorTokens.pressedOverlay})`,+ },+ ':focus-visible': {+ outline: `2px solid ${colorTokens.focusOutline}`,+ outlineOffset: '3px',+ },},ghost: {backgroundColor: 'transparent',- color: colorTokens.accentText,- },- ghostHover: {- backgroundColor: colorTokens.hoverOverlay,+ color: colorTokens.textPrimary,+ ':hover': {+ backgroundImage: `linear-gradient(${colorTokens.hoverOverlay}, ${colorTokens.hoverOverlay})`,+ },+ ':active': {+ backgroundImage: `linear-gradient(${colorTokens.pressedOverlay}, ${colorTokens.pressedOverlay})`,+ },+ ':focus-visible': {+ outline: `2px solid ${colorTokens.focusOutline}`,+ outlineOffset: '3px',+ },},- ghostActive: {- backgroundColor: colorTokens.pressedOverlay,+ destructive: {+ backgroundColor: colorTokens.negative,+ color: 'white',+ ':hover': {+ backgroundImage: `linear-gradient(${colorTokens.hoverOverlay}, ${colorTokens.hoverOverlay})`,+ },+ ':active': {+ backgroundImage: `linear-gradient(${colorTokens.pressedOverlay}, ${colorTokens.pressedOverlay})`,+ },+ ':focus-visible': {+ outline: `2px solid ${colorTokens.negative}`,+ outlineOffset: '3px',+ },},});/**- * Size styles+ * Button variant type derived from the variants StyleX object*/-const sizes = stylex.create({- sm: {- paddingBlock: spacingTokens.space1,- paddingInline: spacingTokens.space2,- fontSize: '0.75rem',- lineHeight: 1.333,- },- md: {- paddingBlock: spacingTokens.space2,- paddingInline: spacingTokens.space3,- fontSize: '0.875rem',- lineHeight: 1.429,- },- lg: {- paddingBlock: spacingTokens.space3,- paddingInline: spacingTokens.space4,- fontSize: '1rem',- lineHeight: 1.25,- },-});+export type ButtonVariant = keyof typeof variants;++export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {+ /**+ * The visual style variant of the button.+ * @default 'primary'+ */+ variant?: ButtonVariant;+ /**+ * Whether the button is in a loading state.+ * @default false+ */+ loading?: boolean;+ /**+ * Content to render inside the button.+ */+ children: ReactNode;+}/*** Loading state styles@@ -154,13 +156,13 @@ const loadingStyles = stylex.create({animationTimingFunction: 'linear',animationIterationCount: 'infinite',},- spinnerPrimary: {+ spinnerLight: {borderTopColor: 'white',borderLeftColor: 'white',borderBottomColor: 'white',borderRightColor: 'transparent',},- spinnerSecondary: {+ spinnerDark: {borderTopColor: colorTokens.textPrimary,borderLeftColor: colorTokens.textPrimary,borderBottomColor: colorTokens.textPrimary,@@ -169,30 +171,22 @@ const loadingStyles = stylex.create({});/**- * A versatile button component with multiple variants and sizes.+ * A versatile button component with multiple variants.** Styles use XDS theme tokens via StyleX.* Wrap your app in <Theme> to apply a theme.** @example* ```tsx- * <Button variant="primary" size="md">Click me</Button>+ * <Button variant="primary">Click me</Button>* <Button variant="secondary" loading>Saving...</Button>+ * <Button variant="destructive">Delete</Button>* ```*/export const Button = forwardRef<HTMLButtonElement, ButtonProps>(- (- {- variant = 'primary',- size = 'md',- loading = false,- disabled,- children,- ...props- },- ref- ) => {+ ({ variant = 'primary', loading = false, disabled, children, ...props }, ref) => {const isDisabled = disabled || loading;+ const useLightSpinner = variant === 'primary' || variant === 'destructive';return (<button@@ -200,7 +194,6 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(disabled={isDisabled}{...stylex.props(styles.base,- sizes[size],variants[variant],isDisabled && styles.disabled,loading && loadingStyles.loading@@ -211,9 +204,7 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(<span{...stylex.props(loadingStyles.spinner,- variant === 'primary'- ? loadingStyles.spinnerPrimary- : loadingStyles.spinnerSecondary+ useLightSpinner ? loadingStyles.spinnerLight : loadingStyles.spinnerDark)}/>)}diff --git a/packages/core/src/Button/index.ts b/packages/core/src/Button/index.tsindex 1beee9a2fa..91663463e8 100644--- a/packages/core/src/Button/index.ts+++ b/packages/core/src/Button/index.ts@@ -1,11 +1,11 @@/*** @file index.ts* @input Imports Button component and types from Button.tsx- * @output Exports Button, ButtonProps, ButtonVariant, ButtonSize+ * @output Exports Button, ButtonProps, ButtonVariant* @position Component entry point; re-exported by /packages/core/src/index.ts** SYNC: When modified, update this header and /packages/core/src/Button/README.md*/export { Button } from './Button';-export type { ButtonProps, ButtonVariant, ButtonSize } from './Button';+export type { ButtonProps, ButtonVariant } from './Button';diff --git a/packages/core/src/theme/Theme.tsx b/packages/core/src/theme/Theme.tsxindex abb333c6ba..a0fb79e316 100644--- a/packages/core/src/theme/Theme.tsx+++ b/packages/core/src/theme/Theme.tsx@@ -19,6 +19,7 @@import React, { createContext, useContext, useMemo } from 'react';import * as stylex from '@stylexjs/stylex';import type { Theme as ThemeType, ThemeMode } from './types';+import { publicVariables } from './publicVariables.stylex';/*** Theme context value@@ -71,17 +72,6 @@ const wrapperStyles = stylex.create({},});-/**- * Convert runtime overrides to CSS style object- */-function overridesToStyle(overrides: Record<string, string>): React.CSSProperties {- const style: Record<string, string> = {};- for (const [varName, value] of Object.entries(overrides)) {- style[varName] = value;- }- return style as React.CSSProperties;-}-/*** Theme provider component*@@ -97,35 +87,30 @@ export function Theme({// Get the color-scheme style based on modeconst colorSchemeStyle =- mode === 'dark' ? wrapperStyles.dark :- mode === 'light' ? wrapperStyles.light :- wrapperStyles.system;+ mode === 'dark'+ ? wrapperStyles.dark+ : mode === 'light'+ ? wrapperStyles.light+ : wrapperStyles.system;// Get StyleX props for all theme stylesconst stylexProps = stylex.props(wrapperStyles.base,colorSchemeStyle,+ publicVariables.all,theme.colorTheme,- theme.elevationTheme- );-- // Convert runtime overrides to inline styles- const overrideStyles = useMemo(- () => overridesToStyle(theme.overrides),- [theme.overrides]+ theme.elevationTheme,+ theme.spacingTheme,+ theme.radiusTheme,+ theme.transitionTheme,+ theme.typographyTheme);- // Merge StyleX styles with runtime overrides- const mergedStyle = {- ...stylexProps.style,- ...overrideStyles,- };-return (<ThemeContext.Provider value={contextValue}><divclassName={stylexProps.className}- style={mergedStyle}+ style={stylexProps.style}data-theme={mode === 'system' ? undefined : mode}>{children}diff --git a/packages/core/src/theme/createTheme.ts b/packages/core/src/theme/createTheme.tsdeleted file mode 100644index 9ff6f46e3d..0000000000--- a/packages/core/src/theme/createTheme.ts+++ /dev/null@@ -1,171 +0,0 @@-/**- * createTheme - Create an XDS theme with color pair support- *- * Public API accepts [light, dark] tuples for LLM-friendliness.- * Internally converted to CSS light-dark() function.- *- * Usage:- * ```ts- * const theme = createTheme({- * name: 'my-theme',- * tokens: {- * color: {- * accent: ['#0066cc', '#66b3ff'], // [light, dark]- * textPrimary: '#333333', // same for both modes- * },- * },- * });- * ```- */--import type { Theme, ThemeConfig, ThemeTokenOverrides, ColorValue } from './types';-import { colorTheme, elevationTheme } from './themes.stylex';-import { colorTokens, elevationTokens, spacingTokens, radiusTokens, transitionTokens, typographyTokens } from './tokens.stylex';--let themeCounter = 0;--/**- * Extract CSS variable name from a StyleX token value- * StyleX tokens look like "var(--xabc123)" - we need the "--xabc123" part- */-function extractVarName(tokenValue: string): string | null {- const match = tokenValue.match(/var\((--[^,)]+)/);- return match ? match[1] : null;-}--/**- * Build a map of token names to CSS variable names- */-function buildTokenVarMap(tokens: Record<string, string>): Record<string, string> {- const map: Record<string, string> = {};- for (const [name, value] of Object.entries(tokens)) {- const varName = extractVarName(value);- if (varName) {- map[name] = varName;- }- }- return map;-}--// Pre-build the variable maps-const colorVarMap = buildTokenVarMap(colorTokens as unknown as Record<string, string>);-const elevationVarMap = buildTokenVarMap(elevationTokens as unknown as Record<string, string>);-const spacingVarMap = buildTokenVarMap(spacingTokens as unknown as Record<string, string>);-const radiusVarMap = buildTokenVarMap(radiusTokens as unknown as Record<string, string>);-const transitionVarMap = buildTokenVarMap(transitionTokens as unknown as Record<string, string>);-const typographyVarMap = buildTokenVarMap(typographyTokens as unknown as Record<string, string>);--/**- * Check if a value is a color pair [light, dark]- */-function isColorPair(value: ColorValue): value is [string, string] {- return Array.isArray(value) && value.length === 2;-}--/**- * Convert a ColorValue to a CSS string- * - [light, dark] becomes 'light-dark(light, dark)'- * - Single string stays as-is- */-function colorValueToString(value: ColorValue): string {- if (isColorPair(value)) {- return `light-dark(${value[0]}, ${value[1]})`;- }- return value;-}--/**- * Process token overrides and build runtime CSS variable map- */-function processOverrides(tokens: ThemeTokenOverrides | undefined): Record<string, string> {- const overrides: Record<string, string> = {};-- if (!tokens) {- return overrides;- }-- // Process color tokens- if (tokens.color) {- for (const [name, value] of Object.entries(tokens.color)) {- const varName = colorVarMap[name];- if (varName && value !== undefined) {- overrides[varName] = colorValueToString(value);- }- }- }-- // Process elevation tokens- if (tokens.elevation) {- for (const [name, value] of Object.entries(tokens.elevation)) {- const varName = elevationVarMap[name];- if (varName && value !== undefined) {- overrides[varName] = colorValueToString(value);- }- }- }-- // Process spacing tokens- if (tokens.spacing) {- for (const [name, value] of Object.entries(tokens.spacing)) {- const varName = spacingVarMap[name];- if (varName && value !== undefined) {- overrides[varName] = value;- }- }- }-- // Process radius tokens- if (tokens.radius) {- for (const [name, value] of Object.entries(tokens.radius)) {- const varName = radiusVarMap[name];- if (varName && value !== undefined) {- overrides[varName] = value;- }- }- }-- // Process transition tokens- if (tokens.transition) {- for (const [name, value] of Object.entries(tokens.transition)) {- const varName = transitionVarMap[name];- if (varName && value !== undefined) {- overrides[varName] = value;- }- }- }-- // Process typography tokens- if (tokens.typography) {- for (const [name, value] of Object.entries(tokens.typography)) {- const varName = typographyVarMap[name];- if (varName && value !== undefined) {- overrides[varName] = value;- }- }- }-- return overrides;-}--/**- * Create a theme from token definitions- *- * Token values can be:- * - Single strings: `accent: '#0066cc'` (same for light and dark)- * - Color pairs: `accent: ['#0066cc', '#66b3ff']` ([light, dark])- *- * Color pairs are converted to CSS light-dark() internally.- */-export function createTheme(config: ThemeConfig = {}): Theme {- const name = config.name ?? `xds-theme-${++themeCounter}`;- const overrides = processOverrides(config.tokens);-- return {- name,- // Use pre-compiled StyleX themes with light-dark() values- colorTheme,- elevationTheme,- // Runtime CSS variable overrides for custom values- overrides,- };-}diff --git a/packages/core/src/theme/themes.stylex.ts b/packages/core/src/theme/defaultTheme.stylex.tssimilarity index 57%rename from packages/core/src/theme/themes.stylex.tsrename to packages/core/src/theme/defaultTheme.stylex.tsindex f0abb579e2..12a363af0b 100644--- a/packages/core/src/theme/themes.stylex.ts+++ b/packages/core/src/theme/defaultTheme.stylex.ts@@ -1,21 +1,34 @@/**- * XDS Pre-defined Themes+ * XDS Default Theme*- * Uses CSS light-dark() function for automatic light/dark mode switching.- * The browser picks the appropriate value based on the color-scheme property.+ * A complete theme template that can be copied and customized.+ * Uses CSS light-dark() for automatic light/dark mode switching.+ *+ * To create a custom theme:+ * 1. Copy this file+ * 2. Rename it (e.g., myBrandTheme.stylex.ts)+ * 3. Update the values with your brand colors/spacing+ * 4. Export from index.ts*/import * as stylex from '@stylexjs/stylex';import {colorTokens,elevationTokens,+ spacingTokens,+ radiusTokens,+ transitionTokens,+ typographyTokens,} from './tokens.stylex';+import type { Theme } from './types';-/**- * Color theme with light-dark() values- * Automatically adapts based on color-scheme CSS property- */-export const colorTheme = stylex.createTheme(colorTokens, {+// =============================================================================+// Color Theme+// =============================================================================+// Override tokens with light-dark() values for automatic mode switching.+// Format: 'light-dark(lightValue, darkValue)'++const colorTheme = stylex.createTheme(colorTokens, {// Core semanticaccent: 'light-dark(#0064E0, #2694FE)',accentDeemphasized: 'light-dark(#0082FB33, #0082FB3F)',@@ -128,19 +141,78 @@ export const colorTheme = stylex.createTheme(colorTokens, {yellowText: 'light-dark(#F57F17, #FFF9C4)',});-/**- * Elevation theme with light-dark() values- */-export const elevationTheme = stylex.createTheme(elevationTokens, {+// =============================================================================+// Elevation Theme+// =============================================================================++const elevationTheme = stylex.createTheme(elevationTokens, {base: 'light-dark(0px 0px 1px rgba(0, 0, 0, 0.1), 0px 0px 1px #111112)',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))',+ 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))',});-// Legacy exports for backwards compatibility-export const lightTheme = colorTheme;-export const darkTheme = colorTheme;-export const lightElevationTheme = elevationTheme;-export const darkElevationTheme = elevationTheme;+// =============================================================================+// Spacing Theme+// =============================================================================++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+// =============================================================================++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 defaultTheme: Theme = {+ name: 'default',+ colorTheme,+ elevationTheme,+ spacingTheme,+ radiusTheme,+ transitionTheme,+ typographyTheme,+};diff --git a/packages/core/src/theme/defaultTheme.ts b/packages/core/src/theme/defaultTheme.tsdeleted file mode 100644index a1bdc50240..0000000000--- a/packages/core/src/theme/defaultTheme.ts+++ /dev/null@@ -1,30 +0,0 @@-/**- * XDS Default Theme- *- * Pre-configured theme using the built-in light and dark mode values.- * Uses the pre-compiled StyleX themes without any overrides.- */--import { createTheme } from './createTheme';--/**- * Default theme with built-in light/dark mode support- *- * This theme uses the standard XDS color palette.- * For custom themes, use createTheme() with your own token overrides:- *- * ```ts- * const myTheme = createTheme({- * name: 'my-brand',- * tokens: {- * color: {- * accent: ['#0066cc', '#66b3ff'], // [light, dark]- * },- * },- * });- * ```- */-export const defaultTheme = createTheme({- name: 'default',- // No token overrides - uses the pre-compiled StyleX themes-});diff --git a/packages/core/src/theme/index.ts b/packages/core/src/theme/index.tsindex 913e32d528..32e0ad77d3 100644--- a/packages/core/src/theme/index.ts+++ b/packages/core/src/theme/index.ts@@ -2,17 +2,16 @@* XDS Theme System** Exports:- * - createTheme: Create a theme with light-dark() color values* - Theme: Provider component that applies theme* - useTheme: Hook to access current theme+ * - defaultTheme: XDS default theme+ * - neutralTheme: Neutral grayscale theme* - Token exports for direct use in StyleX- * - Types for theme configuration*/-export { createTheme } from './createTheme';export { Theme, useTheme } from './Theme';-export { defaultTheme } from './defaultTheme';-export { shadcnTheme } from './shadcnTheme';+export { defaultTheme } from './defaultTheme.stylex';+export { neutralTheme } from './neutralTheme.stylex';// Export tokens for use in custom componentsexport {@@ -24,28 +23,4 @@ export {typographyTokens,} from './tokens.stylex';-// Export pre-compiled themes (for advanced use)-export {- colorTheme,- elevationTheme,- // Legacy exports for backwards compatibility- lightTheme,- darkTheme,- lightElevationTheme,- darkElevationTheme,-} from './themes.stylex';--export type {- Theme as ThemeType,- ThemeConfig,- ThemeTokenOverrides,- ThemeMode,- ColorTokenOverrides,- SpacingTokenOverrides,- RadiusTokenOverrides,- ElevationTokenOverrides,- TransitionTokenOverrides,- TypographyTokenOverrides,- ColorPair,- ColorValue,-} from './types';+export type { Theme as ThemeType, ThemeMode } from './types';diff --git a/packages/core/src/theme/neutralTheme.stylex.ts b/packages/core/src/theme/neutralTheme.stylex.tsnew file mode 100644index 0000000000..0c9773423c--- /dev/null+++ b/packages/core/src/theme/neutralTheme.stylex.ts@@ -0,0 +1,237 @@+/**+ * Neutral Theme+ *+ * A grayscale theme with neutral colors and modern aesthetics.+ * Uses oklch color space for perceptually uniform colors.+ *+ * Inspired by shadcn/ui's default color scheme.+ *+ * To create a custom theme:+ * 1. Copy this file+ * 2. Rename it (e.g., myBrandTheme.stylex.ts)+ * 3. Update the color values with your brand colors+ * 4. Export from index.ts+ */++import * as stylex from '@stylexjs/stylex';+import {+ colorTokens,+ elevationTokens,+ spacingTokens,+ radiusTokens,+ transitionTokens,+ typographyTokens,+} from './tokens.stylex';+import type { Theme } from './types';++// =============================================================================+// Color Theme+// =============================================================================+// Neutral grayscale palette using oklch color space.+// Format: 'light-dark(lightValue, darkValue)'++const colorTheme = stylex.createTheme(colorTokens, {+ // Core semantic - neutral grayscale palette+ accent: 'light-dark(oklch(0.205 0 0), oklch(0.922 0 0))',+ accentDeemphasized: 'light-dark(oklch(0.97 0 0), oklch(0.269 0 0))',+ accentText: 'light-dark(oklch(0.205 0 0), oklch(0.985 0 0))',+ surface: 'light-dark(oklch(1 0 0), oklch(0.145 0 0))',+ wash: 'light-dark(oklch(0.97 0 0), oklch(0.269 0 0))',+ overlay: 'light-dark(oklch(0 0 0 / 50%), oklch(0 0 0 / 80%))',+ hoverOverlay: 'light-dark(oklch(0 0 0 / 5%), oklch(1 0 0 / 5%))',+ pressedOverlay: 'light-dark(oklch(0 0 0 / 10%), oklch(1 0 0 / 10%))',+ focusOutline: 'light-dark(oklch(0.708 0 0), oklch(0.556 0 0))',+ deemphasized: 'light-dark(oklch(0.97 0 0), oklch(0.269 0 0))',++ // Text+ textPrimary: 'light-dark(oklch(0.145 0 0), oklch(0.985 0 0))',+ textSecondary: 'light-dark(oklch(0.556 0 0), oklch(0.708 0 0))',+ textDisabled: 'light-dark(oklch(0.708 0 0), oklch(0.439 0 0))',+ textLink: 'light-dark(oklch(0.205 0 0), oklch(0.922 0 0))',+ textPlaceholder: 'light-dark(oklch(0.556 0 0), oklch(0.556 0 0))',++ // Icon+ iconPrimary: 'light-dark(oklch(0.145 0 0), oklch(0.985 0 0))',+ iconSecondary: 'light-dark(oklch(0.556 0 0), oklch(0.708 0 0))',+ iconTertiary: 'light-dark(oklch(0.708 0 0), oklch(0.556 0 0))',+ iconDisabled: 'light-dark(oklch(0.708 0 0), oklch(0.439 0 0))',++ // Surface variants+ card: 'light-dark(oklch(1 0 0), oklch(0.205 0 0))',+ popover: 'light-dark(oklch(1 0 0), oklch(0.269 0 0))',+ navbar: 'light-dark(oklch(0.985 0 0), oklch(0.205 0 0))',++ // Status/Sentiment+ positive: 'light-dark(oklch(0.6 0.15 145), oklch(0.7 0.15 145))',+ positiveDeemphasized:+ 'light-dark(oklch(0.6 0.15 145 / 20%), oklch(0.7 0.15 145 / 20%))',+ negative: 'light-dark(oklch(0.577 0.245 27.325), oklch(0.704 0.191 22.216))',+ negativeDeemphasized:+ 'light-dark(oklch(0.577 0.245 27.325 / 20%), oklch(0.704 0.191 22.216 / 20%))',+ warning: 'light-dark(oklch(0.828 0.189 84.429), oklch(0.769 0.188 70.08))',+ warningDeemphasized:+ 'light-dark(oklch(0.828 0.189 84.429 / 20%), oklch(0.769 0.188 70.08 / 20%))',+ educational:+ 'light-dark(oklch(0.488 0.243 264.376), oklch(0.627 0.265 303.9))',+ educationalDeemphasized:+ 'light-dark(oklch(0.488 0.243 264.376 / 20%), oklch(0.627 0.265 303.9 / 20%))',++ // Divider+ divider: 'light-dark(oklch(0.922 0 0), oklch(1 0 0 / 10%))',+ dividerHighContrast: 'light-dark(oklch(0.708 0 0), oklch(0.556 0 0))',+ dividerEmphasized: 'light-dark(oklch(0.85 0 0), oklch(0.371 0 0))',++ // Disabled/Effects+ disabledOverlay: 'light-dark(oklch(1 0 0 / 50%), oklch(0.145 0 0 / 50%))',+ glimmer: 'light-dark(oklch(0.922 0 0), oklch(0.371 0 0))',+ glimmerHighContrast: 'light-dark(oklch(0.85 0 0), oklch(0.439 0 0))',+ shadowElevation: 'light-dark(oklch(0 0 0 / 10%), oklch(0 0 0 / 30%))',++ // Literal color sets - Blue+ blueBackground:+ 'light-dark(oklch(0.488 0.243 264.376 / 20%), oklch(0.488 0.243 264.376 / 20%))',+ blueBorder: 'light-dark(oklch(0.488 0.243 264.376), oklch(0.488 0.243 264.376))',+ blueIcon: 'light-dark(oklch(0.488 0.243 264.376), oklch(0.488 0.243 264.376))',+ blueText: 'light-dark(oklch(0.398 0.2 264), oklch(0.7 0.2 264))',++ // Cyan+ cyanBackground:+ 'light-dark(oklch(0.6 0.118 184.704 / 20%), oklch(0.696 0.17 162.48 / 20%))',+ cyanBorder: 'light-dark(oklch(0.6 0.118 184.704), oklch(0.696 0.17 162.48))',+ cyanIcon: 'light-dark(oklch(0.6 0.118 184.704), oklch(0.696 0.17 162.48))',+ cyanText: 'light-dark(oklch(0.398 0.07 184), oklch(0.8 0.1 162))',++ // Gray+ grayBackground: 'light-dark(oklch(0.922 0 0 / 50%), oklch(0.371 0 0 / 50%))',+ grayBorder: 'light-dark(oklch(0.708 0 0), oklch(0.556 0 0))',+ grayIcon: 'light-dark(oklch(0.556 0 0), oklch(0.708 0 0))',+ grayText: 'light-dark(oklch(0.145 0 0), oklch(0.985 0 0))',++ // Green+ greenBackground:+ 'light-dark(oklch(0.6 0.118 184.704 / 20%), oklch(0.696 0.17 162.48 / 20%))',+ greenBorder: 'light-dark(oklch(0.6 0.118 184.704), oklch(0.696 0.17 162.48))',+ greenIcon: 'light-dark(oklch(0.6 0.118 184.704), oklch(0.696 0.17 162.48))',+ greenText: 'light-dark(oklch(0.398 0.07 184), oklch(0.8 0.1 162))',++ // Orange+ orangeBackground:+ 'light-dark(oklch(0.646 0.222 41.116 / 20%), oklch(0.645 0.246 16.439 / 20%))',+ orangeBorder:+ 'light-dark(oklch(0.646 0.222 41.116), oklch(0.645 0.246 16.439))',+ orangeIcon:+ 'light-dark(oklch(0.646 0.222 41.116), oklch(0.645 0.246 16.439))',+ orangeText: 'light-dark(oklch(0.5 0.18 41), oklch(0.8 0.2 16))',++ // Pink+ pinkBackground:+ 'light-dark(oklch(0.627 0.265 303.9 / 20%), oklch(0.627 0.265 303.9 / 20%))',+ pinkBorder: 'light-dark(oklch(0.627 0.265 303.9), oklch(0.627 0.265 303.9))',+ pinkIcon: 'light-dark(oklch(0.627 0.265 303.9), oklch(0.627 0.265 303.9))',+ pinkText: 'light-dark(oklch(0.5 0.2 303), oklch(0.8 0.2 303))',++ // Purple+ purpleBackground:+ 'light-dark(oklch(0.627 0.265 303.9 / 20%), oklch(0.627 0.265 303.9 / 20%))',+ purpleBorder: 'light-dark(oklch(0.627 0.265 303.9), oklch(0.627 0.265 303.9))',+ purpleIcon: 'light-dark(oklch(0.627 0.265 303.9), oklch(0.627 0.265 303.9))',+ purpleText: 'light-dark(oklch(0.5 0.2 303), oklch(0.8 0.2 303))',++ // Red+ redBackground:+ 'light-dark(oklch(0.577 0.245 27.325 / 20%), oklch(0.704 0.191 22.216 / 20%))',+ redBorder:+ 'light-dark(oklch(0.577 0.245 27.325), oklch(0.704 0.191 22.216))',+ redIcon: 'light-dark(oklch(0.577 0.245 27.325), oklch(0.704 0.191 22.216))',+ redText: 'light-dark(oklch(0.45 0.2 27), oklch(0.85 0.15 22))',++ // Teal+ tealBackground:+ 'light-dark(oklch(0.6 0.118 184.704 / 20%), oklch(0.696 0.17 162.48 / 20%))',+ tealBorder: 'light-dark(oklch(0.6 0.118 184.704), oklch(0.696 0.17 162.48))',+ tealIcon: 'light-dark(oklch(0.6 0.118 184.704), oklch(0.696 0.17 162.48))',+ tealText: 'light-dark(oklch(0.398 0.07 184), oklch(0.8 0.1 162))',++ // Yellow+ yellowBackground:+ 'light-dark(oklch(0.828 0.189 84.429 / 20%), oklch(0.769 0.188 70.08 / 20%))',+ yellowBorder:+ 'light-dark(oklch(0.828 0.189 84.429), oklch(0.769 0.188 70.08))',+ yellowIcon: 'light-dark(oklch(0.828 0.189 84.429), oklch(0.769 0.188 70.08))',+ yellowText: 'light-dark(oklch(0.6 0.15 84), oklch(0.9 0.15 70))',+});++// =============================================================================+// Elevation Theme+// =============================================================================++const elevationTheme = stylex.createTheme(elevationTokens, {+ base: 'light-dark(0 1px 2px oklch(0 0 0 / 5%), 0 1px 2px oklch(0 0 0 / 20%))',+ thumb:+ 'light-dark(0 1px 3px oklch(0 0 0 / 10%), 0 1px 3px oklch(0 0 0 / 30%))',+ dialog:+ 'light-dark(0 4px 6px oklch(0 0 0 / 10%) 0 12px 24px oklch(0 0 0 / 15%), 0 4px 6px oklch(0 0 0 / 25%) 0 12px 24px oklch(0 0 0 / 35%))',+ hover:+ 'light-dark(0 2px 4px oklch(0 0 0 / 5%) 0 4px 12px oklch(0 0 0 / 10%), 0 2px 4px oklch(0 0 0 / 15%) 0 4px 12px oklch(0 0 0 / 20%))',+ menu: 'light-dark(0 2px 4px oklch(0 0 0 / 5%) 0 4px 8px oklch(0 0 0 / 10%), 0 2px 4px oklch(0 0 0 / 15%) 0 4px 8px oklch(0 0 0 / 20%))',+});++// =============================================================================+// Spacing Theme+// =============================================================================++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+// =============================================================================++const radiusTheme = stylex.createTheme(radiusTokens, {+ rounded: '9999px',+ container: '0.75rem',+ element: '0.625rem',+ content: '0.375rem',+});++// =============================================================================+// Transition Theme+// =============================================================================++const transitionTheme = stylex.createTheme(transitionTokens, {+ fast: '0.15s ease',+ normal: '0.2s ease',+});++// =============================================================================+// Typography Theme+// =============================================================================++const typographyTheme = stylex.createTheme(typographyTokens, {+ fontFamilyBody: 'Geist, "Geist Fallback", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',+ fontFamilyCode: '"Geist Mono", "SF Mono", Monaco, Consolas, monospace',+ fontFamilyHeading: 'Geist, "Geist Fallback", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',+});++// =============================================================================+// Theme Export+// =============================================================================++export const neutralTheme: Theme = {+ name: 'neutral',+ colorTheme,+ elevationTheme,+ spacingTheme,+ radiusTheme,+ transitionTheme,+ typographyTheme,+};diff --git a/packages/core/src/theme/publicVariables.stylex.ts b/packages/core/src/theme/publicVariables.stylex.tsnew file mode 100644index 0000000000..c4b0a01c0c--- /dev/null+++ b/packages/core/src/theme/publicVariables.stylex.ts@@ -0,0 +1,108 @@+/**+ * Public CSS Variables+ *+ * Maps internal StyleX tokens to public CSS variable names.+ * These can be used by consumers without needing StyleX.+ *+ * Usage in plain CSS:+ * background-color: var(--xds-surface);+ * color: var(--xds-text-primary);+ */++import * as stylex from '@stylexjs/stylex';+import {+ colorTokens,+ elevationTokens,+ spacingTokens,+ radiusTokens,+ transitionTokens,+ typographyTokens,+} from './tokens.stylex';++export const publicVariables = stylex.create({+ all: {+ // Color tokens+ '--xds-accent': colorTokens.accent,+ '--xds-accent-deemphasized': colorTokens.accentDeemphasized,+ '--xds-accent-text': colorTokens.accentText,+ '--xds-surface': colorTokens.surface,+ '--xds-wash': colorTokens.wash,+ '--xds-overlay': colorTokens.overlay,+ '--xds-hover-overlay': colorTokens.hoverOverlay,+ '--xds-pressed-overlay': colorTokens.pressedOverlay,+ '--xds-focus-outline': colorTokens.focusOutline,+ '--xds-deemphasized': colorTokens.deemphasized,++ // Text+ '--xds-text-primary': colorTokens.textPrimary,+ '--xds-text-secondary': colorTokens.textSecondary,+ '--xds-text-disabled': colorTokens.textDisabled,+ '--xds-text-link': colorTokens.textLink,+ '--xds-text-placeholder': colorTokens.textPlaceholder,++ // Icon+ '--xds-icon-primary': colorTokens.iconPrimary,+ '--xds-icon-secondary': colorTokens.iconSecondary,+ '--xds-icon-tertiary': colorTokens.iconTertiary,+ '--xds-icon-disabled': colorTokens.iconDisabled,++ // Surface variants+ '--xds-card': colorTokens.card,+ '--xds-popover': colorTokens.popover,+ '--xds-navbar': colorTokens.navbar,++ // Status+ '--xds-positive': colorTokens.positive,+ '--xds-positive-deemphasized': colorTokens.positiveDeemphasized,+ '--xds-negative': colorTokens.negative,+ '--xds-negative-deemphasized': colorTokens.negativeDeemphasized,+ '--xds-warning': colorTokens.warning,+ '--xds-warning-deemphasized': colorTokens.warningDeemphasized,+ '--xds-educational': colorTokens.educational,+ '--xds-educational-deemphasized': colorTokens.educationalDeemphasized,++ // Divider+ '--xds-divider': colorTokens.divider,+ '--xds-divider-high-contrast': colorTokens.dividerHighContrast,+ '--xds-divider-emphasized': colorTokens.dividerEmphasized,++ // Effects+ '--xds-disabled-overlay': colorTokens.disabledOverlay,+ '--xds-glimmer': colorTokens.glimmer,+ '--xds-glimmer-high-contrast': colorTokens.glimmerHighContrast,+ '--xds-shadow-elevation': colorTokens.shadowElevation,++ // Elevation+ '--xds-elevation-base': elevationTokens.base,+ '--xds-elevation-thumb': elevationTokens.thumb,+ '--xds-elevation-dialog': elevationTokens.dialog,+ '--xds-elevation-hover': elevationTokens.hover,+ '--xds-elevation-menu': elevationTokens.menu,++ // Spacing+ '--xds-space-0': spacingTokens.space0,+ '--xds-space-0-5': spacingTokens.space0_5,+ '--xds-space-1': spacingTokens.space1,+ '--xds-space-2': spacingTokens.space2,+ '--xds-space-3': spacingTokens.space3,+ '--xds-space-4': spacingTokens.space4,+ '--xds-space-5': spacingTokens.space5,+ '--xds-space-6': spacingTokens.space6,+ '--xds-space-7': spacingTokens.space7,++ // Radius+ '--xds-radius-rounded': radiusTokens.rounded,+ '--xds-radius-container': radiusTokens.container,+ '--xds-radius-element': radiusTokens.element,+ '--xds-radius-content': radiusTokens.content,++ // Transition+ '--xds-transition-fast': transitionTokens.fast,+ '--xds-transition-normal': transitionTokens.normal,++ // Typography+ '--xds-font-body': typographyTokens.fontFamilyBody,+ '--xds-font-code': typographyTokens.fontFamilyCode,+ '--xds-font-heading': typographyTokens.fontFamilyHeading,+ },+});diff --git a/packages/core/src/theme/types.ts b/packages/core/src/theme/types.tsindex 6d88738a23..8baeb5df58 100644--- a/packages/core/src/theme/types.ts+++ b/packages/core/src/theme/types.ts@@ -1,8 +1,5 @@/*** XDS Theme Type Definitions- *- * Supports color pairs [light, dark] for easy theme creation.- * Internally converted to CSS light-dark() function.*/// eslint-disable-next-line @typescript-eslint/no-explicit-any@@ -14,200 +11,7 @@ type StyleXTheme = any;export type ThemeMode = 'system' | 'light' | 'dark';/**- * Color pair tuple [light, dark]- */-export type ColorPair = [light: string, dark: string];--/**- * Color token value - can be a single string or [light, dark] pair- * Single strings are used as-is (for both modes)- * Pairs are converted to light-dark(light, dark)- */-export type ColorValue = string | ColorPair;--/**- * Color token overrides for createTheme- * Each value can be:- * - A single string: `accent: '#0066cc'` (same for both modes)- * - A color pair: `accent: ['#0066cc', '#66b3ff']` ([light, dark])- */-export interface ColorTokenOverrides {- // Core semantic- accent?: ColorValue;- accentDeemphasized?: ColorValue;- accentText?: ColorValue;- surface?: ColorValue;- wash?: ColorValue;- overlay?: ColorValue;- hoverOverlay?: ColorValue;- pressedOverlay?: ColorValue;- focusOutline?: ColorValue;- deemphasized?: ColorValue;-- // Text- textPrimary?: ColorValue;- textSecondary?: ColorValue;- textDisabled?: ColorValue;- textLink?: ColorValue;- textPlaceholder?: ColorValue;-- // Icon- iconPrimary?: ColorValue;- iconSecondary?: ColorValue;- iconTertiary?: ColorValue;- iconDisabled?: ColorValue;-- // Surface variants- card?: ColorValue;- popover?: ColorValue;- navbar?: ColorValue;-- // Status/Sentiment- positive?: ColorValue;- positiveDeemphasized?: ColorValue;- negative?: ColorValue;- negativeDeemphasized?: ColorValue;- warning?: ColorValue;- warningDeemphasized?: ColorValue;- educational?: ColorValue;- educationalDeemphasized?: ColorValue;-- // Divider- divider?: ColorValue;- dividerHighContrast?: ColorValue;- dividerEmphasized?: ColorValue;-- // Disabled/Effects- disabledOverlay?: ColorValue;- glimmer?: ColorValue;- glimmerHighContrast?: ColorValue;- shadowElevation?: ColorValue;-- // Literal color sets- blueBackground?: ColorValue;- blueBorder?: ColorValue;- blueIcon?: ColorValue;- blueText?: ColorValue;- cyanBackground?: ColorValue;- cyanBorder?: ColorValue;- cyanIcon?: ColorValue;- cyanText?: ColorValue;- grayBackground?: ColorValue;- grayBorder?: ColorValue;- grayIcon?: ColorValue;- grayText?: ColorValue;- greenBackground?: ColorValue;- greenBorder?: ColorValue;- greenIcon?: ColorValue;- greenText?: ColorValue;- orangeBackground?: ColorValue;- orangeBorder?: ColorValue;- orangeIcon?: ColorValue;- orangeText?: ColorValue;- pinkBackground?: ColorValue;- pinkBorder?: ColorValue;- pinkIcon?: ColorValue;- pinkText?: ColorValue;- purpleBackground?: ColorValue;- purpleBorder?: ColorValue;- purpleIcon?: ColorValue;- purpleText?: ColorValue;- redBackground?: ColorValue;- redBorder?: ColorValue;- redIcon?: ColorValue;- redText?: ColorValue;- tealBackground?: ColorValue;- tealBorder?: ColorValue;- tealIcon?: ColorValue;- tealText?: ColorValue;- yellowBackground?: ColorValue;- yellowBorder?: ColorValue;- yellowIcon?: ColorValue;- yellowText?: ColorValue;-}--/**- * Spacing token overrides- */-export interface SpacingTokenOverrides {- space0?: string;- space0_5?: string;- space1?: string;- space2?: string;- space3?: string;- space4?: string;- space5?: string;- space6?: string;- space7?: string;- containerPaddingPage?: string;- containerPaddingCard?: string;- containerPaddingPopover?: string;- containerGapSections?: string;-}--/**- * Radius token overrides- */-export interface RadiusTokenOverrides {- rounded?: string;- container?: string;- element?: string;- content?: string;-}--/**- * Elevation token overrides- * Values can be a single string or [light, dark] pair- */-export interface ElevationTokenOverrides {- base?: ColorValue;- thumb?: ColorValue;- dialog?: ColorValue;- hover?: ColorValue;- menu?: ColorValue;-}--/**- * Transition token overrides- */-export interface TransitionTokenOverrides {- fast?: string;- normal?: string;-}--/**- * Typography token overrides- */-export interface TypographyTokenOverrides {- fontFamilyBody?: string;- fontFamilyCode?: string;- fontFamilyHeading?: string;-}--/**- * Theme token overrides for createTheme- */-export interface ThemeTokenOverrides {- color?: ColorTokenOverrides;- spacing?: SpacingTokenOverrides;- radius?: RadiusTokenOverrides;- elevation?: ElevationTokenOverrides;- transition?: TransitionTokenOverrides;- typography?: TypographyTokenOverrides;-}--/**- * Theme configuration- */-export interface ThemeConfig {- /** Theme name */- name?: string;- /** Token overrides - color values can be [light, dark] pairs */- tokens?: ThemeTokenOverrides;-}--/**- * Created theme object+ * Theme object - pre-compiled StyleX theme*/export interface Theme {/** Theme name */@@ -216,6 +20,12 @@ export interface Theme {colorTheme: StyleXTheme;/** Elevation theme StyleX styles */elevationTheme: StyleXTheme;- /** Runtime CSS variable overrides */- overrides: Record<string, string>;+ /** Spacing theme StyleX styles (optional) */+ spacingTheme?: StyleXTheme;+ /** Radius theme StyleX styles (optional) */+ radiusTheme?: StyleXTheme;+ /** Transition theme StyleX styles (optional) */+ transitionTheme?: StyleXTheme;+ /** Typography theme StyleX styles (optional) */+ typographyTheme?: StyleXTheme;}