Skip to content

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

TypeScript

refactor(core): remove legacy StyleX theme system (#513)

Cindy Zhang55ad0a56929a
diff --git a/apps/storybook/stories/Table.stories.tsx b/apps/storybook/stories/Table.stories.tsx
index ad4439da83..8d2bde247f 100644
--- a/apps/storybook/stories/Table.stories.tsx
+++ b/apps/storybook/stories/Table.stories.tsx
@@ -7,7 +7,12 @@ import {
pixel,
} from '@xds/core/Table';
import type {XDSTableColumn} from '@xds/core/Table';
-import {colorRaw, spacingRaw, radiusRaw, textSizeRaw} from '@xds/core/theme';
+import {
+ colorDefaults,
+ spacingDefaults,
+ radiusDefaults,
+ textSizeDefaults,
+} from '@xds/core/theme';
// =============================================================================
// Sample Data
@@ -198,17 +203,17 @@ export const CustomCellRenderer: Story = {
renderCell: item => (
<span
style={{
- padding: `${spacingRaw['--spacing-0-5']} ${spacingRaw['--spacing-2']}`,
- borderRadius: radiusRaw['--radius-content'],
- fontSize: textSizeRaw['--text-xsm'],
+ padding: `${spacingDefaults['--spacing-0-5']} ${spacingDefaults['--spacing-2']}`,
+ borderRadius: radiusDefaults['--radius-content'],
+ fontSize: textSizeDefaults['--text-xsm'],
backgroundColor:
item.role === 'Engineer'
- ? colorRaw['--color-blue-background']
- : colorRaw['--color-purple-background'],
+ ? colorDefaults['--color-blue-background']
+ : colorDefaults['--color-purple-background'],
color:
item.role === 'Engineer'
- ? colorRaw['--color-blue-text']
- : colorRaw['--color-purple-text'],
+ ? colorDefaults['--color-blue-text']
+ : colorDefaults['--color-purple-text'],
}}>
{item.role}
</span>
diff --git a/packages/core/src/AspectRatio/XDSAspectRatio.tsx b/packages/core/src/AspectRatio/XDSAspectRatio.tsx
index 5949426d25..449af5fe31 100644
--- a/packages/core/src/AspectRatio/XDSAspectRatio.tsx
+++ b/packages/core/src/AspectRatio/XDSAspectRatio.tsx
@@ -12,30 +12,11 @@
'use client';
-import {
- forwardRef,
- useContext,
- type HTMLAttributes,
- type ReactNode,
-} from 'react';
+import {forwardRef, type HTMLAttributes, type ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import type {StyleXStyles} from '@stylexjs/stylex';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
import {xdsClassName, mergeProps} from '../utils';
-// =============================================================================
-// Module Augmentation - Register component styles with ComponentStyles
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- aspectRatio?: {
- /** Root container styles */
- root?: ThemeStyleXStyles;
- };
- }
-}
export interface XDSAspectRatioProps extends Omit<
HTMLAttributes<HTMLElement>,
'style' | 'className'
@@ -87,14 +68,12 @@ const styles = stylex.create({
*/
export const XDSAspectRatio = forwardRef<HTMLElement, XDSAspectRatioProps>(
function XDSAspectRatio({ratio, children, xstyle, ...props}, ref) {
- const themeContext = useContext(ThemeContext);
- const rootOverride = themeContext?.theme.components?.aspectRatio?.root;
return (
<div
ref={ref as React.Ref<HTMLDivElement>}
{...mergeProps(
xdsClassName('aspect-ratio'),
- stylex.props(styles.container, xstyle, rootOverride),
+ stylex.props(styles.container, xstyle),
)}
style={{aspectRatio: ratio}}
{...props}>
diff --git a/packages/core/src/Avatar/XDSAvatar.tsx b/packages/core/src/Avatar/XDSAvatar.tsx
index 6af75bf427..befef9b51c 100644
--- a/packages/core/src/Avatar/XDSAvatar.tsx
+++ b/packages/core/src/Avatar/XDSAvatar.tsx
@@ -13,21 +13,13 @@
'use client';
-import {
- forwardRef,
- useContext,
- useState,
- type HTMLAttributes,
- type ReactNode,
-} from 'react';
+import {forwardRef, useState, type HTMLAttributes, type ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import {
colorVars,
typographyVars,
fontWeightVars,
} from '../theme/tokens.stylex';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
import {XDSAvatarSizeContext} from './XDSAvatarSizeContext';
import {xdsClassName, mergeProps} from '../utils';
@@ -165,19 +157,6 @@ const dynamicStyles = stylex.create({
}),
});
-// =============================================================================
-// Module Augmentation - Register Avatar's style surfaces with ComponentStyles
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- avatar?: {
- root?: ThemeStyleXStyles;
- fallback?: ThemeStyleXStyles;
- };
- }
-}
-
export interface XDSAvatarProps extends Omit<
HTMLAttributes<HTMLDivElement>,
'children'
@@ -288,11 +267,6 @@ export const XDSAvatar = forwardRef<HTMLDivElement, XDSAvatarProps>(
const accessibleName = alt || name || 'Avatar';
const numericSize = resolveSize(size);
- // Get theme context for component-level overrides (optional)
- const themeContext = useContext(ThemeContext);
- const rootOverride = themeContext?.theme.components?.avatar?.root;
- const fallbackOverride = themeContext?.theme.components?.avatar?.fallback;
-
return (
<XDSAvatarSizeContext.Provider value={numericSize}>
<div
@@ -302,7 +276,7 @@ export const XDSAvatar = forwardRef<HTMLDivElement, XDSAvatarProps>(
data-testid={testId}
{...mergeProps(
xdsClassName('avatar', {size}),
- stylex.props(styles.wrapper, rootOverride),
+ stylex.props(styles.wrapper),
)}
{...props}>
<div
@@ -328,13 +302,12 @@ export const XDSAvatar = forwardRef<HTMLDivElement, XDSAvatarProps>(
{...stylex.props(
styles.fallback,
dynamicStyles.fontSize(numericSize),
- fallbackOverride,
)}>
{getInitials(name)}
</div>
)}
{showIcon && (
- <div {...stylex.props(styles.fallback, fallbackOverride)}>
+ <div {...stylex.props(styles.fallback)}>
<DefaultIcon size={numericSize} />
</div>
)}
diff --git a/packages/core/src/Badge/XDSBadge.tsx b/packages/core/src/Badge/XDSBadge.tsx
index 9a2c3b02a5..e7f812294b 100644
--- a/packages/core/src/Badge/XDSBadge.tsx
+++ b/packages/core/src/Badge/XDSBadge.tsx
@@ -13,12 +13,7 @@
'use client';
-import {
- forwardRef,
- useContext,
- type HTMLAttributes,
- type ReactNode,
-} from 'react';
+import {forwardRef, type HTMLAttributes, type ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import {
colorVars,
@@ -28,8 +23,6 @@ import {
fontWeightVars,
lineHeightVars,
} from '../theme/tokens.stylex';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
import {xdsClassName, mergeProps} from '../utils';
/**
@@ -88,19 +81,6 @@ const variants = stylex.create({
*/
export type XDSBadgeVariant = keyof typeof variants;
-// =============================================================================
-// Module Augmentation - Register Badge's style surfaces with ComponentStyles
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- badge?: {
- root?: ThemeStyleXStyles;
- variants?: Partial<Record<XDSBadgeVariant, ThemeStyleXStyles>>;
- };
- }
-}
-
export interface XDSBadgeProps extends Omit<
HTMLAttributes<HTMLSpanElement>,
'className' | 'style'
@@ -139,24 +119,12 @@ export const XDSBadge = forwardRef<HTMLSpanElement, XDSBadgeProps>(
({variant = 'neutral', children, icon, ...props}, ref) => {
const isDot = children == null && icon == null;
- // Get theme context for component-level overrides (optional)
- const themeContext = useContext(ThemeContext);
- const rootOverride = themeContext?.theme.components?.badge?.root;
- const variantOverride =
- themeContext?.theme.components?.badge?.variants?.[variant];
-
return (
<span
ref={ref}
{...mergeProps(
xdsClassName('badge', {variant}),
- stylex.props(
- styles.base,
- variants[variant],
- rootOverride,
- variantOverride,
- isDot && styles.dot,
- ),
+ stylex.props(styles.base, variants[variant], isDot && styles.dot),
)}
{...props}>
{icon}
diff --git a/packages/core/src/Button/XDSButton.tsx b/packages/core/src/Button/XDSButton.tsx
index b9c6649266..28183e0b13 100644
--- a/packages/core/src/Button/XDSButton.tsx
+++ b/packages/core/src/Button/XDSButton.tsx
@@ -17,7 +17,6 @@
import {
forwardRef,
- useContext,
useTransition,
type ButtonHTMLAttributes,
type ReactElement,
@@ -34,7 +33,6 @@ import {
fontWeightVars,
lineHeightVars,
} from '../theme/tokens.stylex';
-import {ThemeContext} from '../theme/ThemeContext';
import {XDSTooltip} from '../Layer/XDSTooltip';
import {XDSSpinner} from '../Spinner';
import type {XDSIconProps} from '../Icon/XDSIcon';
@@ -197,20 +195,6 @@ export type XDSButtonVariant = keyof typeof variants;
*/
export type XDSButtonSize = keyof typeof sizeStyles;
-// =============================================================================
-// Module Augmentation - Register Button's variant type with ComponentStyles
-// =============================================================================
-// This allows themes to provide type-safe variant overrides for Button
-// without requiring theme/types.ts to import from Button (avoiding circular deps)
-
-declare module '../theme/types' {
- interface ComponentStyles {
- button?: {
- variants?: Partial<Record<XDSButtonVariant, StyleXStyles>>;
- };
- }
-}
-
export interface XDSButtonProps extends Omit<
ButtonHTMLAttributes<HTMLButtonElement>,
'children' | 'disabled'
@@ -346,11 +330,6 @@ export const XDSButton = forwardRef<HTMLButtonElement, XDSButtonProps>(
const useLightSpinner = variant === 'primary' || variant === 'destructive';
const isIconOnly = icon != null && children == null;
- // Get theme context for component-level overrides (optional)
- const themeContext = useContext(ThemeContext);
- const themeVariantOverride =
- themeContext?.theme.components?.button?.variants?.[variant];
-
const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {
if (onClickAction) {
e.preventDefault();
@@ -385,7 +364,6 @@ export const XDSButton = forwardRef<HTMLButtonElement, XDSButtonProps>(
styles.base,
sizeStyles[size],
variants[variant],
- themeVariantOverride,
isIconOnly && styles.iconOnly,
buttonDisabled && styles.disabled,
isLoadingState && loadingStyles.loading,
diff --git a/packages/core/src/Calendar/XDSCalendar.tsx b/packages/core/src/Calendar/XDSCalendar.tsx
index a131154cb2..e632349813 100644
--- a/packages/core/src/Calendar/XDSCalendar.tsx
+++ b/packages/core/src/Calendar/XDSCalendar.tsx
@@ -15,7 +15,6 @@
import {
forwardRef,
- useContext,
useState,
useMemo,
useCallback,
@@ -47,8 +46,6 @@ import {
getWeekNumber,
formatAccessibleDate,
} from './utils';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
import {xdsClassName, mergeProps} from '../utils';
// =============================================================================
@@ -59,19 +56,23 @@ import {xdsClassName, mergeProps} from '../utils';
* ISO 8601 date string in YYYY-MM-DD format.
* Example: "2026-01-28"
*/
+
export type ISODateString =
`${number}${number}${number}${number}-${number}${number}-${number}${number}`;
/** Day of week: 0 = Sunday through 6 = Saturday */
+
export type DayOfWeek = 0 | 1 | 2 | 3 | 4 | 5 | 6;
/** Date range with start and end dates */
+
export interface DateRange {
start: ISODateString;
end: ISODateString;
}
/** Imperative handle for XDSCalendar ref */
+
export interface XDSCalendarHandle {
/** Navigate the calendar to show the month containing the given date */
navigateTo: (date: ISODateString) => void;
@@ -162,18 +163,6 @@ interface XDSCalendarRangeProps extends XDSCalendarBaseProps {
onChange?: (value: DateRange) => void;
}
-// =============================================================================
-// Module Augmentation - Register component styles with ComponentStyles
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- calendar?: {
- /** Root container styles */
- root?: ThemeStyleXStyles;
- };
- }
-}
export type XDSCalendarProps = XDSCalendarSingleProps | XDSCalendarRangeProps;
// =============================================================================
@@ -208,10 +197,6 @@ export const XDSCalendar = forwardRef<XDSCalendarHandle, XDSCalendarProps>(
...rest
} = props;
- // Get theme context for component-level overrides
- const themeContext = useContext(ThemeContext);
- const rootOverride = themeContext?.theme.components?.calendar?.root;
-
// Today's date (memoized)
const today = useMemo(() => new Date(), []);
@@ -364,7 +349,7 @@ export const XDSCalendar = forwardRef<XDSCalendarHandle, XDSCalendarProps>(
<div
{...mergeProps(
xdsClassName('calendar', {mode}),
- stylex.props(calendarStyles.calendar, rootOverride),
+ stylex.props(calendarStyles.calendar),
)}
{...rest}>
{/* Header with navigation */}
diff --git a/packages/core/src/Card/XDSCard.tsx b/packages/core/src/Card/XDSCard.tsx
index e9883d2706..d27d461b4d 100644
--- a/packages/core/src/Card/XDSCard.tsx
+++ b/packages/core/src/Card/XDSCard.tsx
@@ -1,6 +1,6 @@
/**
* @file XDSCard.tsx
- * @input Uses container utility, StyleX, ThemeContext
+ * @input Uses container utility, StyleX
* @output Exports XDSCard component and XDSCardProps
* @position Core card container component
*
@@ -12,30 +12,13 @@
'use client';
-import {forwardRef, useContext, type ReactNode} from 'react';
+import {forwardRef, type ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import {colorVars, radiusVars, elevationVars} from '../theme/tokens.stylex';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
import {container} from '../Layout/container.stylex';
import type {SizeValue} from '../utils/types';
import {xdsClassName, mergeProps} from '../utils';
-// =============================================================================
-// Module Augmentation - Register XDSCard's themeable properties
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- card?: {
- /** Outer container styles (background, border, shadow, border-radius) */
- container?: ThemeStyleXStyles;
- /** Inner content styles (padding) */
- content?: ThemeStyleXStyles;
- };
- }
-}
-
const styles = stylex.create({
// Outer wrapper: visual styling with clip for border-radius
cardOuter: {
@@ -153,11 +136,6 @@ export const XDSCard = forwardRef<HTMLDivElement, XDSCardProps>(
},
ref,
) {
- // Get theme context for component-level overrides
- const themeContext = useContext(ThemeContext);
- const containerOverride = themeContext?.theme.components?.card?.container;
- const contentOverride = themeContext?.theme.components?.card?.content;
-
// Only enable scrolling when card has a fixed height (not null/undefined and not "auto")
const hasFixedHeight = height != null && height !== 'auto';
@@ -168,7 +146,6 @@ export const XDSCard = forwardRef<HTMLDivElement, XDSCardProps>(
xdsClassName('card'),
stylex.props(
styles.cardOuter,
- containerOverride,
dynamicStyles.sizing(
width ?? null,
height ?? null,
@@ -189,7 +166,6 @@ export const XDSCard = forwardRef<HTMLDivElement, XDSCardProps>(
paddingOuterY: 'spacing4',
}),
isFullBleed && styles.fullBleed,
- contentOverride,
)}>
{children}
</div>
diff --git a/packages/core/src/Center/XDSCenter.tsx b/packages/core/src/Center/XDSCenter.tsx
index 87d05e81fd..c312caf1ab 100644
--- a/packages/core/src/Center/XDSCenter.tsx
+++ b/packages/core/src/Center/XDSCenter.tsx
@@ -12,17 +12,10 @@
'use client';
-import {
- forwardRef,
- useContext,
- type HTMLAttributes,
- type ReactNode,
-} from 'react';
+import {forwardRef, type HTMLAttributes, type ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import type {StyleXStyles} from '@stylexjs/stylex';
import type {SizeValue} from '../utils/types';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
import {xdsClassName, mergeProps} from '../utils';
const styles = stylex.create({
@@ -50,18 +43,6 @@ const dynamicStyles = stylex.create({
export type CenterAxis = 'both' | 'horizontal' | 'vertical';
-// =============================================================================
-// Module Augmentation - Register component styles with ComponentStyles
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- center?: {
- /** Root container styles */
- root?: ThemeStyleXStyles;
- };
- }
-}
export interface XDSCenterProps extends Omit<
HTMLAttributes<HTMLDivElement>,
'style' | 'className'
@@ -130,9 +111,6 @@ export const XDSCenter = forwardRef<HTMLDivElement, XDSCenterProps>(
},
ref,
) {
- const themeContext = useContext(ThemeContext);
- const rootOverride = themeContext?.theme.components?.center?.root;
-
const stylexProps = mergeProps(
xdsClassName('center', {axis}),
stylex.props(
@@ -142,7 +120,6 @@ export const XDSCenter = forwardRef<HTMLDivElement, XDSCenterProps>(
styles.justifyContentCenter,
dynamicStyles.sizing(width ?? null, height ?? null),
xstyle,
- rootOverride,
),
);
diff --git a/packages/core/src/CheckboxInput/XDSCheckboxInput.tsx b/packages/core/src/CheckboxInput/XDSCheckboxInput.tsx
index a04ceaefae..5f60f4b5e5 100644
--- a/packages/core/src/CheckboxInput/XDSCheckboxInput.tsx
+++ b/packages/core/src/CheckboxInput/XDSCheckboxInput.tsx
@@ -15,7 +15,6 @@
import {
forwardRef,
- useContext,
useId,
useOptimistic,
useTransition,
@@ -35,8 +34,6 @@ import {XDSFieldLabel} from '../Field/XDSFieldLabel';
import {XDSFieldStatus} from '../Field/XDSFieldStatus';
import type {XDSIconType} from '../Icon';
import type {XDSInputStatus} from '../Field/types';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
import {XDSSpinner} from '../Spinner';
import {xdsClassName, mergeProps} from '../utils';
@@ -199,20 +196,6 @@ const labelWrapperSizeStyles = stylex.create({
export type XDSCheckboxInputSize = keyof typeof wrapperSizeStyles;
-// =============================================================================
-// Module Augmentation - Register component styles with ComponentStyles
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- checkboxInput?: {
- /** Root container styles */
- root?: ThemeStyleXStyles;
- /** Visual checkbox styles */
- checkbox?: ThemeStyleXStyles;
- };
- }
-}
export interface XDSCheckboxInputProps {
/**
* Label text for the checkbox (always rendered for accessibility).
@@ -330,11 +313,6 @@ export const XDSCheckboxInput = forwardRef<
},
ref,
) => {
- const themeContext = useContext(ThemeContext);
- const rootOverride = themeContext?.theme.components?.checkboxInput?.root;
- const checkboxOverride =
- themeContext?.theme.components?.checkboxInput?.checkbox;
-
const id = useId();
const descriptionID = useId();
const statusMessageID = useId();
@@ -360,7 +338,6 @@ export const XDSCheckboxInput = forwardRef<
{...stylex.props(
styles.container,
isLabelHidden && styles.containerLabelHidden,
- rootOverride,
!isDisabled && stylex.defaultMarker(),
)}>
<div
@@ -398,7 +375,6 @@ export const XDSCheckboxInput = forwardRef<
{...stylex.props(
styles.checkbox,
checkboxSizeStyles[size],
- checkboxOverride,
isCheckedOrIndeterminate
? styles.checkboxChecked
: styles.checkboxUnchecked,
diff --git a/packages/core/src/DateInput/XDSDateInput.tsx b/packages/core/src/DateInput/XDSDateInput.tsx
index 4ea1c72e81..c1dcb13256 100644
--- a/packages/core/src/DateInput/XDSDateInput.tsx
+++ b/packages/core/src/DateInput/XDSDateInput.tsx
@@ -15,7 +15,6 @@
import {
forwardRef,
- useContext,
useId,
useState,
useCallback,
@@ -120,28 +119,13 @@ const sizeStyles = stylex.create({
export type XDSDateInputSize = keyof typeof sizeStyles;
// Re-export shared types for convenience
+
export type {
XDSInputStatus as XDSDateInputStatus,
XDSInputStatusType as XDSDateInputStatusType,
} from '../Field';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
import {xdsClassName, mergeProps} from '../utils';
-// =============================================================================
-// Module Augmentation - Register component styles with ComponentStyles
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- dateInput?: {
- /** Input wrapper styles */
- wrapper?: ThemeStyleXStyles;
- /** Text input styles */
- input?: ThemeStyleXStyles;
- };
- }
-}
export interface XDSDateInputProps {
/**
* Label text for the input (required for accessibility).
@@ -283,10 +267,6 @@ export const XDSDateInput = forwardRef<HTMLInputElement, XDSDateInputProps>(
},
ref,
) => {
- const themeContext = useContext(ThemeContext);
- const wrapperOverride = themeContext?.theme.components?.dateInput?.wrapper;
- const inputOverride = themeContext?.theme.components?.dateInput?.input;
-
const id = useId();
const descriptionID = useId();
const statusMessageID = useId();
@@ -487,7 +467,6 @@ export const XDSDateInput = forwardRef<HTMLInputElement, XDSDateInputProps>(
status && inputStatusBorderStyles[status.type],
status && inputStatusHoverShadowStyles[status.type],
status && inputStatusFocusWithinStyles[status.type],
- wrapperOverride,
),
)}>
<button
@@ -521,7 +500,6 @@ export const XDSDateInput = forwardRef<HTMLInputElement, XDSDateInputProps>(
styles.input,
isDisabled && styles.inputDisabled,
!isInputValid && styles.inputInvalid,
- inputOverride,
)}
/>
{isBusy && <XDSSpinner size="sm" />}
diff --git a/packages/core/src/Dialog/XDSDialog.tsx b/packages/core/src/Dialog/XDSDialog.tsx
index 7429297d39..9197f06e05 100644
--- a/packages/core/src/Dialog/XDSDialog.tsx
+++ b/packages/core/src/Dialog/XDSDialog.tsx
@@ -15,7 +15,6 @@
import {
forwardRef,
- useContext,
useEffect,
useRef,
type DialogHTMLAttributes,
@@ -28,8 +27,6 @@ import {
transitionVars,
elevationVars,
} from '../theme/tokens.stylex';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
import {xdsClassName, mergeProps} from '../utils';
/**
@@ -144,18 +141,6 @@ function formatPosition(value: number | string | undefined): string | null {
return typeof value === 'number' ? `${value}px` : value;
}
-// =============================================================================
-// Module Augmentation - Register Dialog's style surfaces with ComponentStyles
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- dialog?: {
- root?: ThemeStyleXStyles;
- };
- }
-}
-
export interface XDSDialogProps extends Omit<
DialogHTMLAttributes<HTMLDialogElement>,
'children'
@@ -337,10 +322,6 @@ export const XDSDialog = forwardRef<HTMLDialogElement, XDSDialogProps>(
const isFullscreen = variant === 'fullscreen';
const hasPosition = position != null && !isFullscreen;
- // Get theme context for component-level overrides (optional)
- const themeContext = useContext(ThemeContext);
- const rootOverride = themeContext?.theme.components?.dialog?.root;
-
return (
<dialog
ref={setRefs}
@@ -361,7 +342,6 @@ export const XDSDialog = forwardRef<HTMLDialogElement, XDSDialogProps>(
position?.left,
),
isFullscreen && styles.fullscreen,
- rootOverride,
),
)}
{...props}>
diff --git a/packages/core/src/Divider/XDSDivider.tsx b/packages/core/src/Divider/XDSDivider.tsx
index de950e66b8..dffad704df 100644
--- a/packages/core/src/Divider/XDSDivider.tsx
+++ b/packages/core/src/Divider/XDSDivider.tsx
@@ -12,12 +12,7 @@
'use client';
-import {
- forwardRef,
- useContext,
- type HTMLAttributes,
- type ReactNode,
-} from 'react';
+import {forwardRef, type HTMLAttributes, type ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import type {StyleXStyles} from '@stylexjs/stylex';
import {
@@ -26,24 +21,8 @@ import {
textSizeVars,
lineHeightVars,
} from '../theme/tokens.stylex';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
import {xdsClassName, mergeProps} from '../utils';
-// =============================================================================
-// Module Augmentation - Register Divider's style surfaces with ComponentStyles
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- divider?: {
- root?: ThemeStyleXStyles;
- line?: ThemeStyleXStyles;
- label?: ThemeStyleXStyles;
- };
- }
-}
-
export interface XDSDividerProps extends Omit<
HTMLAttributes<HTMLElement>,
'style' | 'className' | 'children'
@@ -164,12 +143,6 @@ export const XDSDivider = forwardRef<HTMLElement, XDSDividerProps>(
) {
const isHorizontal = orientation === 'horizontal';
- // Get theme context for component-level overrides (optional)
- const themeContext = useContext(ThemeContext);
- const rootOverride = themeContext?.theme.components?.divider?.root;
- const lineOverride = themeContext?.theme.components?.divider?.line;
- const labelOverride = themeContext?.theme.components?.divider?.label;
-
return (
<div
ref={ref as React.Ref<HTMLDivElement>}
@@ -183,7 +156,6 @@ export const XDSDivider = forwardRef<HTMLElement, XDSDividerProps>(
(isHorizontal
? fullBleedStyles.horizontal
: fullBleedStyles.vertical),
- rootOverride,
xstyle,
),
)}
@@ -192,7 +164,6 @@ export const XDSDivider = forwardRef<HTMLElement, XDSDividerProps>(
{...stylex.props(
isHorizontal ? lineStyles.horizontalLine : lineStyles.verticalLine,
lineStyles[variant],
- lineOverride,
)}
/>
{label && (
@@ -200,7 +171,6 @@ export const XDSDivider = forwardRef<HTMLElement, XDSDividerProps>(
{...stylex.props(
labelStyles.label,
!isHorizontal && labelStyles.verticalLabel,
- labelOverride,
)}>
{label}
</div>
@@ -212,7 +182,6 @@ export const XDSDivider = forwardRef<HTMLElement, XDSDividerProps>(
? lineStyles.horizontalLine
: lineStyles.verticalLine,
lineStyles[variant],
- lineOverride,
)}
/>
)}
diff --git a/packages/core/src/DropdownMenu/XDSDropdownMenu.tsx b/packages/core/src/DropdownMenu/XDSDropdownMenu.tsx
index 5b5e390806..9be61cb8a8 100644
--- a/packages/core/src/DropdownMenu/XDSDropdownMenu.tsx
+++ b/packages/core/src/DropdownMenu/XDSDropdownMenu.tsx
@@ -14,7 +14,6 @@
'use client';
import React, {
- useContext,
useCallback,
useId,
useMemo,
@@ -38,8 +37,6 @@ import {
typographyVars,
textSizeVars,
} from '../theme/tokens.stylex';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
const styles = stylex.create({
// Dropdown container
@@ -115,19 +112,6 @@ const styles = stylex.create({
},
});
-// =============================================================================
-// Module Augmentation - Register DropdownMenu's style surfaces with ComponentStyles
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- dropdownMenu?: {
- root?: ThemeStyleXStyles;
- item?: ThemeStyleXStyles;
- };
- }
-}
-
// =============================================================================
// Types
// =============================================================================
@@ -328,10 +312,6 @@ export function XDSDropdownMenu({
}: XDSDropdownMenuProps) {
const menuId = useId();
- // Get theme context for component-level overrides (optional)
- const themeContext = useContext(ThemeContext);
- const rootOverride = themeContext?.theme.components?.dropdownMenu?.root;
- const itemOverride = themeContext?.theme.components?.dropdownMenu?.item;
const buttonRef = useRef<HTMLButtonElement>(null);
// Internal state for uncontrolled mode
@@ -520,7 +500,6 @@ export function XDSDropdownMenu({
styles.item,
isHighlighted && styles.itemHighlighted,
item.isDisabled && styles.itemDisabled,
- itemOverride,
)}>
{children ? children(item) : <DefaultItem item={item} />}
</div>
@@ -614,10 +593,7 @@ export function XDSDropdownMenu({
</XDSButton>
{layer.render(
- <div
- id={menuId}
- role="menu"
- {...stylex.props(styles.dropdown, rootOverride)}>
+ <div id={menuId} role="menu" {...stylex.props(styles.dropdown)}>
{renderOptions()}
</div>,
{
diff --git a/packages/core/src/Field/XDSField.tsx b/packages/core/src/Field/XDSField.tsx
index db592eeb8a..f4b6964b77 100644
--- a/packages/core/src/Field/XDSField.tsx
+++ b/packages/core/src/Field/XDSField.tsx
@@ -13,12 +13,7 @@
'use client';
-import {
- forwardRef,
- useContext,
- type HTMLAttributes,
- type ReactNode,
-} from 'react';
+import {forwardRef, type HTMLAttributes, type ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import {XDSFieldLabel} from './XDSFieldLabel';
import {XDSFieldStatus} from './XDSFieldStatus';
@@ -30,8 +25,6 @@ import {
typographyVars,
} from '../theme/tokens.stylex';
import type {XDSIconType} from '../Icon';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
import {xdsClassName, mergeProps} from '../utils';
const styles = stylex.create({
@@ -100,20 +93,6 @@ export interface XDSFieldStatus {
messageID?: string;
}
-// =============================================================================
-// Module Augmentation - Register component styles with ComponentStyles
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- field?: {
- /** Root container styles */
- root?: ThemeStyleXStyles;
- /** Description text styles */
- description?: ThemeStyleXStyles;
- };
- }
-}
export interface XDSFieldProps extends Omit<
HTMLAttributes<HTMLDivElement>,
'children'
@@ -207,18 +186,10 @@ export const XDSField = forwardRef<HTMLDivElement, XDSFieldProps>(
},
ref,
) => {
- const themeContext = useContext(ThemeContext);
- const rootOverride = themeContext?.theme.components?.field?.root;
- const descriptionOverride =
- themeContext?.theme.components?.field?.description;
-
return (
<div
ref={ref}
- {...mergeProps(
- xdsClassName('field'),
- stylex.props(styles.container, rootOverride),
- )}
+ {...mergeProps(xdsClassName('field'), stylex.props(styles.container))}
{...props}>
<XDSFieldLabel
label={label}
@@ -235,7 +206,6 @@ export const XDSField = forwardRef<HTMLDivElement, XDSFieldProps>(
{...stylex.props(
styles.description,
isLabelHidden && styles.labelHidden,
- descriptionOverride,
)}>
{description}
</span>
diff --git a/packages/core/src/Grid/XDSGrid.tsx b/packages/core/src/Grid/XDSGrid.tsx
index 67db3f3eca..17b5cb97ef 100644
--- a/packages/core/src/Grid/XDSGrid.tsx
+++ b/packages/core/src/Grid/XDSGrid.tsx
@@ -12,38 +12,20 @@
'use client';
-import {
- forwardRef,
- useContext,
- type HTMLAttributes,
- type ReactNode,
-} from 'react';
+import {forwardRef, type HTMLAttributes, type ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import type {StyleXStyles} from '@stylexjs/stylex';
import {spacingVars} from '../theme/tokens.stylex';
import type {SpacingScale} from '../Layout';
import type {SizeValue} from '../utils/types';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
import {xdsClassName, mergeProps} from '../utils';
/**
* Grid alignment options for align-items and justify-items.
*/
-export type GridAlignment = 'start' | 'center' | 'end' | 'stretch';
-// =============================================================================
-// Module Augmentation - Register component styles with ComponentStyles
-// =============================================================================
+export type GridAlignment = 'start' | 'center' | 'end' | 'stretch';
-declare module '../theme/types' {
- interface ComponentStyles {
- grid?: {
- /** Root container styles */
- root?: ThemeStyleXStyles;
- };
- }
-}
export interface XDSGridProps extends Omit<
HTMLAttributes<HTMLElement>,
'style' | 'className'
@@ -360,9 +342,6 @@ export const XDSGrid = forwardRef<HTMLElement, XDSGridProps>(function XDSGrid(
},
ref,
) {
- const themeContext = useContext(ThemeContext);
- const rootOverride = themeContext?.theme.components?.grid?.root;
-
// Determine grid-template-columns value
let gridTemplateColumns: string;
let calculatedMaxWidth: number | undefined;
@@ -413,7 +392,6 @@ export const XDSGrid = forwardRef<HTMLElement, XDSGridProps>(function XDSGrid(
align != null && alignStyles[align],
justify != null && justifyStyles[justify],
xstyle,
- rootOverride,
),
)}
style={inlineStyle}
diff --git a/packages/core/src/Icon/XDSIcon.tsx b/packages/core/src/Icon/XDSIcon.tsx
index dec56fb8f9..a9b411915e 100644
--- a/packages/core/src/Icon/XDSIcon.tsx
+++ b/packages/core/src/Icon/XDSIcon.tsx
@@ -1,6 +1,6 @@
/**
* @file XDSIcon.tsx
- * @input Uses React forwardRef/useContext, SVGProps, icon components or semantic icon names
+ * @input Uses React forwardRef/SVGProps, icon components or semantic icon names
* @output Exports XDSIcon component, XDSIconProps, XDSIconColor, XDSIconSize, XDSIconType types
* @position Core implementation; consumed by index.ts, tested by XDSIcon.test.tsx
*
@@ -19,11 +19,9 @@
'use client';
-import {forwardRef, useContext, type ComponentType, type SVGProps} from 'react';
+import {forwardRef, type ComponentType, type SVGProps} from 'react';
import * as stylex from '@stylexjs/stylex';
import {colorVars} from '../theme/tokens.stylex';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
import {useXDSIcon, type XDSIconName} from './IconRegistry';
import {xdsClassName, mergeProps} from '../utils';
@@ -137,18 +135,6 @@ export type XDSIconSize = keyof typeof sizeStyles;
*/
export type XDSIconType = ComponentType<SVGProps<SVGSVGElement>>;
-// =============================================================================
-// Module Augmentation - Register Icon's style surfaces with ComponentStyles
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- icon?: {
- root?: ThemeStyleXStyles;
- };
- }
-}
-
/**
* Props for XDSIcon component.
* Extends SVGProps to allow passing additional SVG attributes (used when icon is a component).
@@ -193,10 +179,6 @@ export interface XDSIconProps extends Omit<
*/
export const XDSIcon = forwardRef<SVGSVGElement, XDSIconProps>(
({icon, color = 'primary', size = 'md', ...props}, ref) => {
- // Get theme context for component-level overrides (optional)
- const themeContext = useContext(ThemeContext);
- const rootOverride = themeContext?.theme.components?.icon?.root;
-
// String mode: resolve from icon registry, wrap in styled span
if (typeof icon === 'string') {
return <IconFromRegistry name={icon} color={color} size={size} />;
@@ -210,12 +192,7 @@ export const XDSIcon = forwardRef<SVGSVGElement, XDSIconProps>(
aria-hidden="true"
{...mergeProps(
xdsClassName('icon', {size, color}),
- stylex.props(
- styles.root,
- colorStyles[color],
- sizeStyles[size],
- rootOverride,
- ),
+ stylex.props(styles.root, colorStyles[color], sizeStyles[size]),
)}
{...props}
/>
diff --git a/packages/core/src/Layer/XDSHoverCard.tsx b/packages/core/src/Layer/XDSHoverCard.tsx
index be54162803..7310318259 100644
--- a/packages/core/src/Layer/XDSHoverCard.tsx
+++ b/packages/core/src/Layer/XDSHoverCard.tsx
@@ -14,14 +14,12 @@
'use client';
import React, {
- useContext,
useLayoutEffect,
useRef,
type ReactElement,
type ReactNode,
} from 'react';
import * as stylex from '@stylexjs/stylex';
-import {ThemeContext} from '../theme/ThemeContext';
import {useXDSHoverCard, type HoverCardFocusTrigger} from './useXDSHoverCard';
import type {LayerAlignment, LayerPlacement} from './useXDSLayer';
import {colorVars} from '../theme/tokens.stylex';
@@ -165,11 +163,6 @@ export function XDSHoverCard({
const wrapperRef = useRef<HTMLElement>(null);
const textOnly = isTextOnly(children);
- // Get theme context for hover indication override
- const themeContext = useContext(ThemeContext);
- const themeHoverIndicationOverride =
- themeContext?.theme.components?.hoverCard?.hoverIndication;
-
// Determine if hover indication should be shown
const showHoverIndication =
hasHoverIndication === true || (hasHoverIndication === 'auto' && textOnly);
@@ -227,7 +220,6 @@ export function XDSHoverCard({
{...stylex.props(
styles.wrapperInline,
showHoverIndication && styles.hoverIndication,
- showHoverIndication && themeHoverIndicationOverride,
)}>
{children}
</span>
diff --git a/packages/core/src/Layer/XDSPopover.tsx b/packages/core/src/Layer/XDSPopover.tsx
index 3f880e9eee..86b600e838 100644
--- a/packages/core/src/Layer/XDSPopover.tsx
+++ b/packages/core/src/Layer/XDSPopover.tsx
@@ -32,19 +32,6 @@ import {
radiusVars,
elevationVars,
} from '../theme/tokens.stylex';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
-
-// =============================================================================
-// Module Augmentation
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- popover?: {
- container?: ThemeStyleXStyles;
- };
- }
-}
// =============================================================================
// Helpers
diff --git a/packages/core/src/Layer/XDSTooltip.tsx b/packages/core/src/Layer/XDSTooltip.tsx
index 3bfc7062bd..abb10f0646 100644
--- a/packages/core/src/Layer/XDSTooltip.tsx
+++ b/packages/core/src/Layer/XDSTooltip.tsx
@@ -14,14 +14,12 @@
'use client';
import React, {
- useContext,
useLayoutEffect,
useRef,
type ReactElement,
type ReactNode,
} from 'react';
import * as stylex from '@stylexjs/stylex';
-import {ThemeContext} from '../theme/ThemeContext';
import {useXDSTooltip, type TooltipFocusTrigger} from './useXDSTooltip';
import type {LayerAlignment, LayerPlacement} from './useXDSLayer';
import {colorVars} from '../theme/tokens.stylex';
@@ -175,11 +173,6 @@ export function XDSTooltip({
const wrapperRef = useRef<HTMLElement>(null);
const textOnly = children != null ? isTextOnly(children) : false;
- // Get theme context for hover indication override
- const themeContext = useContext(ThemeContext);
- const themeHoverIndicationOverride =
- themeContext?.theme.components?.tooltip?.hoverIndication;
-
// Determine if hover indication should be shown
const showHoverIndication =
hasHoverIndication === true || (hasHoverIndication === 'auto' && textOnly);
@@ -270,7 +263,6 @@ export function XDSTooltip({
{...stylex.props(
styles.wrapperInline,
showHoverIndication && styles.hoverIndication,
- showHoverIndication && themeHoverIndicationOverride,
)}>
{children}
</span>
diff --git a/packages/core/src/Layer/componentStyles.ts b/packages/core/src/Layer/componentStyles.ts
deleted file mode 100644
index bbc77b7324..0000000000
--- a/packages/core/src/Layer/componentStyles.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * @file componentStyles.ts
- * @input Uses StyleXStyles from theme/types
- * @output Module augmentation for Layer component styles
- * @position Central type definitions for Layer component theming
- *
- * SYNC: When adding new Layer components, add their style types here.
- */
-
-import type {StyleXStyles} from '../theme/types';
-
-// =============================================================================
-// Module Augmentation - Register Layer component styles with ComponentStyles
-// =============================================================================
-// This allows themes to provide style overrides for Layer components.
-// Centralized here to ensure types are available regardless of which
-// hooks or components are imported.
-
-declare module '../theme/types' {
- interface ComponentStyles {
- hoverCard?: {
- container?: StyleXStyles;
- content?: StyleXStyles;
- hoverIndication?: StyleXStyles;
- };
- tooltip?: {
- container?: StyleXStyles;
- content?: StyleXStyles;
- hoverIndication?: StyleXStyles;
- };
- }
-}
diff --git a/packages/core/src/Layer/index.ts b/packages/core/src/Layer/index.ts
index 34792390bc..b8d8afa754 100644
--- a/packages/core/src/Layer/index.ts
+++ b/packages/core/src/Layer/index.ts
@@ -7,9 +7,6 @@
* SYNC: When adding new Layer files, update exports here
*/
-// Component style type augmentations (side-effect import)
-import './componentStyles';
-
// Core layer hook
export {useXDSLayer} from './useXDSLayer';
export type {
diff --git a/packages/core/src/Layer/useXDSHoverCard.tsx b/packages/core/src/Layer/useXDSHoverCard.tsx
index bc3c00c34e..2a4a0d4c0b 100644
--- a/packages/core/src/Layer/useXDSHoverCard.tsx
+++ b/packages/core/src/Layer/useXDSHoverCard.tsx
@@ -13,14 +13,12 @@
import {
useCallback,
- useContext,
useEffect,
useRef,
type ReactNode,
type RefCallback,
} from 'react';
import * as stylex from '@stylexjs/stylex';
-import {ThemeContext} from '../theme/ThemeContext';
import {
useXDSLayer,
type ContextRenderProps,
@@ -243,13 +241,6 @@ export function useXDSHoverCard(
onHide,
} = options;
- // Get theme context for component-level overrides
- const themeContext = useContext(ThemeContext);
- const themeContainerOverride =
- themeContext?.theme.components?.hoverCard?.container;
- const themeContentOverride =
- themeContext?.theme.components?.hoverCard?.content;
-
// Select margin style based on placement axis
const marginStyle =
placement === 'above' || placement === 'below'
@@ -263,7 +254,7 @@ export function useXDSHoverCard(
});
// StyleX for the popover container
- const popoverXstyle = [styles.container, marginStyle, themeContainerOverride];
+ const popoverXstyle = [styles.container, marginStyle];
const showTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const hideTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
@@ -426,7 +417,7 @@ export function useXDSHoverCard(
return layer.render(
<div
- {...stylex.props(styles.content, themeContentOverride)}
+ {...stylex.props(styles.content)}
onMouseEnter={() => {
isHoveringContentRef.current = true;
clearTimeouts();
@@ -471,15 +462,7 @@ export function useXDSHoverCard(
renderProps,
);
},
- [
- layer,
- placement,
- alignment,
- clearTimeouts,
- scheduleHide,
- themeContentOverride,
- popoverXstyle,
- ],
+ [layer, placement, alignment, clearTimeouts, scheduleHide, popoverXstyle],
);
return {
diff --git a/packages/core/src/Layer/useXDSTooltip.tsx b/packages/core/src/Layer/useXDSTooltip.tsx
index dd3bf76688..9c3e6fdd82 100644
--- a/packages/core/src/Layer/useXDSTooltip.tsx
+++ b/packages/core/src/Layer/useXDSTooltip.tsx
@@ -13,14 +13,12 @@
import {
useCallback,
- useContext,
useEffect,
useRef,
type ReactNode,
type RefCallback,
} from 'react';
import * as stylex from '@stylexjs/stylex';
-import {ThemeContext} from '../theme/ThemeContext';
import {
useXDSLayer,
type ContextRenderProps,
@@ -250,12 +248,6 @@ export function useXDSTooltip(
onHide,
} = options;
- // Get theme context for component-level overrides
- const themeContext = useContext(ThemeContext);
- const themeContainerOverride =
- themeContext?.theme.components?.tooltip?.container;
- const themeContentOverride = themeContext?.theme.components?.tooltip?.content;
-
// Select margin style based on placement axis
const marginStyle =
placement === 'above' || placement === 'below'
@@ -269,7 +261,7 @@ export function useXDSTooltip(
});
// StyleX for the popover container
- const popoverXstyle = [styles.container, marginStyle, themeContainerOverride];
+ const popoverXstyle = [styles.container, marginStyle];
const showTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const hideTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
@@ -391,13 +383,11 @@ export function useXDSTooltip(
};
return layer.render(
- <div {...stylex.props(styles.content, themeContentOverride)}>
- {children}
- </div>,
+ <div {...stylex.props(styles.content)}>{children}</div>,
renderProps,
);
},
- [layer, placement, alignment, themeContentOverride, popoverXstyle],
+ [layer, placement, alignment, popoverXstyle],
);
return {
diff --git a/packages/core/src/Link/XDSLink.tsx b/packages/core/src/Link/XDSLink.tsx
index b77d55ec1c..9b33523632 100644
--- a/packages/core/src/Link/XDSLink.tsx
+++ b/packages/core/src/Link/XDSLink.tsx
@@ -15,7 +15,6 @@
import {
forwardRef,
- useContext,
type AnchorHTMLAttributes,
type MouseEventHandler,
type ReactNode,
@@ -29,8 +28,6 @@ import {
lineHeightVars,
spacingVars,
} from '../theme/tokens.stylex';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
import {XDSIcon} from '../Icon';
import {XDSTooltip} from '../Layer';
import {XDSText} from '../Text';
@@ -114,18 +111,6 @@ const linkColorStyles = stylex.create({
},
});
-// =============================================================================
-// Module Augmentation - Register Link's style surfaces with ComponentStyles
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- link?: {
- root?: ThemeStyleXStyles;
- };
- }
-}
-
export interface XDSLinkProps extends Omit<
AnchorHTMLAttributes<HTMLAnchorElement>,
'children'
@@ -270,10 +255,6 @@ export const XDSLink = forwardRef<HTMLAnchorElement, XDSLinkProps>(
: 'noopener noreferrer'
: rel;
- // Get theme context for component-level overrides (optional)
- const themeContext = useContext(ThemeContext);
- const rootOverride = themeContext?.theme.components?.link?.root;
-
const linkElement = (
<LinkComponent
ref={ref}
@@ -292,7 +273,6 @@ export const XDSLink = forwardRef<HTMLAnchorElement, XDSLinkProps>(
hasUnderline && styles.hasUnderline,
isStandalone && styles.standalone,
isDisabled && styles.disabled,
- rootOverride,
),
)}
{...props}>
diff --git a/packages/core/src/MobileNav/XDSMobileNav.tsx b/packages/core/src/MobileNav/XDSMobileNav.tsx
index a7589d95cf..2d34a72605 100644
--- a/packages/core/src/MobileNav/XDSMobileNav.tsx
+++ b/packages/core/src/MobileNav/XDSMobileNav.tsx
@@ -26,15 +26,12 @@
import {
forwardRef,
useCallback,
- useContext,
useEffect,
useRef,
type ReactNode,
} from 'react';
import * as stylex from '@stylexjs/stylex';
import {colorVars, spacingVars} from '../theme/tokens.stylex';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
import {XDSButton} from '../Button';
import {XDSIcon} from '../Icon';
import {XDSHeading} from '../Text/XDSHeading';
@@ -160,21 +157,6 @@ const dynamicStyles = stylex.create({
}),
});
-// =============================================================================
-// Module Augmentation
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- mobileNav?: {
- /** Root dialog styles */
- root?: ThemeStyleXStyles;
- /** Drawer panel styles */
- drawer?: ThemeStyleXStyles;
- };
- }
-}
-
// =============================================================================
// Types
// =============================================================================
@@ -316,11 +298,6 @@ export const XDSMobileNav = forwardRef<HTMLDialogElement, XDSMobileNavProps>(
[onOpenChange],
);
- // Get theme context for component-level overrides
- const themeContext = useContext(ThemeContext);
- const rootOverride = themeContext?.theme.components?.mobileNav?.root;
- const drawerOverride = themeContext?.theme.components?.mobileNav?.drawer;
-
const isStart = side === 'start';
return (
@@ -336,7 +313,6 @@ export const XDSMobileNav = forwardRef<HTMLDialogElement, XDSMobileNavProps>(
styles.dialog,
styles.backdrop,
isOpen && styles.backdropOpen,
- rootOverride,
),
)}>
{/* Drawer panel */}
@@ -348,7 +324,6 @@ export const XDSMobileNav = forwardRef<HTMLDialogElement, XDSMobileNavProps>(
isStart && isOpen && styles.drawerStartOpen,
!isStart && styles.drawerEnd,
!isStart && isOpen && styles.drawerEndOpen,
- drawerOverride,
)}>
{/* Header with optional title and close button */}
<div {...stylex.props(styles.header, !title && styles.headerNoTitle)}>
diff --git a/packages/core/src/NumberInput/XDSNumberInput.tsx b/packages/core/src/NumberInput/XDSNumberInput.tsx
index 2fab8caece..2aa12dbd73 100644
--- a/packages/core/src/NumberInput/XDSNumberInput.tsx
+++ b/packages/core/src/NumberInput/XDSNumberInput.tsx
@@ -15,7 +15,6 @@
import {
forwardRef,
- useContext,
useId,
useState,
useMemo,
@@ -95,28 +94,13 @@ const sizeStyles = stylex.create({
export type XDSNumberInputSize = keyof typeof sizeStyles;
// Re-export shared types for convenience
+
export type {
XDSInputStatus as XDSNumberInputStatus,
XDSInputStatusType as XDSNumberInputStatusType,
} from '../Field';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
import {xdsClassName, mergeProps} from '../utils';
-// =============================================================================
-// Module Augmentation - Register component styles with ComponentStyles
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- numberInput?: {
- /** Input wrapper styles */
- wrapper?: ThemeStyleXStyles;
- /** Text input styles */
- input?: ThemeStyleXStyles;
- };
- }
-}
export interface XDSNumberInputProps {
/**
* Label text for the input (always rendered for accessibility).
@@ -318,11 +302,6 @@ export const XDSNumberInput = forwardRef<HTMLInputElement, XDSNumberInputProps>(
},
ref,
) => {
- const themeContext = useContext(ThemeContext);
- const wrapperOverride =
- themeContext?.theme.components?.numberInput?.wrapper;
- const inputOverride = themeContext?.theme.components?.numberInput?.input;
-
const id = useId();
const descriptionID = useId();
const statusMessageID = useId();
@@ -483,7 +462,6 @@ export const XDSNumberInput = forwardRef<HTMLInputElement, XDSNumberInputProps>(
status && inputStatusBorderStyles[status.type],
status && inputStatusHoverShadowStyles[status.type],
status && inputStatusFocusWithinStyles[status.type],
- wrapperOverride,
),
)}>
{startIcon && <XDSIcon icon={startIcon} size="sm" color="primary" />}
@@ -511,7 +489,6 @@ export const XDSNumberInput = forwardRef<HTMLInputElement, XDSNumberInputProps>(
styles.input,
isDisabled && styles.inputDisabled,
!isInputValid && styles.inputInvalid,
- inputOverride,
)}
/>
{units && <span {...stylex.props(styles.units)}>{units}</span>}
diff --git a/packages/core/src/Pagination/XDSPagination.tsx b/packages/core/src/Pagination/XDSPagination.tsx
index 9316107ea3..1aa2f727d8 100644
--- a/packages/core/src/Pagination/XDSPagination.tsx
+++ b/packages/core/src/Pagination/XDSPagination.tsx
@@ -17,7 +17,7 @@
'use client';
-import {forwardRef, useContext, useTransition} from 'react';
+import {forwardRef, useTransition} from 'react';
import * as stylex from '@stylexjs/stylex';
import type {StyleXStyles} from '@stylexjs/stylex';
import {
@@ -27,27 +27,12 @@ import {
transitionVars,
textSizeVars,
} from '../theme/tokens.stylex';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
import {XDSButton} from '../Button';
import {XDSIcon} from '../Icon';
import {XDSSelector} from '../Selector';
import {XDSText} from '../Text';
import {xdsClassName, mergeProps} from '../utils';
-// =============================================================================
-// Module Augmentation - Register component styles with ComponentStyles
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- pagination?: {
- /** Root nav container styles */
- root?: ThemeStyleXStyles;
- };
- }
-}
-
// =============================================================================
// Types
// =============================================================================
@@ -335,8 +320,6 @@ export const XDSPagination = forwardRef<HTMLElement, XDSPaginationProps>(
ref,
) {
const [isPending, startTransition] = useTransition();
- const themeContext = useContext(ThemeContext);
- const rootOverride = themeContext?.theme.components?.pagination?.root;
// Compute pagination state
const computedTotalPages =
@@ -507,7 +490,7 @@ export const XDSPagination = forwardRef<HTMLElement, XDSPaginationProps>(
data-testid={testId}
{...mergeProps(
xdsClassName('pagination', {variant, size}),
- stylex.props(styles.root, rootOverride, xstyle),
+ stylex.props(styles.root, xstyle),
)}>
{pageSizeOptions != null && pageSizeOptions.length > 0 && (
<div {...stylex.props(styles.pageSizeSelector)}>
diff --git a/packages/core/src/RadioList/XDSRadioList.tsx b/packages/core/src/RadioList/XDSRadioList.tsx
index 0d21c34008..317c168fb7 100644
--- a/packages/core/src/RadioList/XDSRadioList.tsx
+++ b/packages/core/src/RadioList/XDSRadioList.tsx
@@ -13,11 +13,9 @@
'use client';
-import {createContext, useContext, useId, type ReactNode} from 'react';
+import {createContext, useId, type ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import type {StyleXStyles} from '@stylexjs/stylex';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
import {spacingVars} from '../theme/tokens.stylex';
import {XDSField} from '../Field/XDSField';
import type {XDSInputStatus} from '../Field/types';
@@ -42,18 +40,6 @@ export const RadioListContext = createContext<RadioListContextValue | null>(
null,
);
-// =============================================================================
-// Module Augmentation - Register RadioList's themeable properties
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- radioList?: {
- root?: ThemeStyleXStyles;
- };
- }
-}
-
const styles = stylex.create({
radiogroup: {
display: 'flex',
@@ -172,10 +158,6 @@ export function XDSRadioList({
'data-testid': dataTestId,
children,
}: XDSRadioListProps) {
- // Get theme context for component-level overrides (optional)
- const themeContext = useContext(ThemeContext);
- const rootOverride = themeContext?.theme.components?.radioList?.root;
-
const name = useId();
const inputID = useId();
const descriptionID = useId();
@@ -231,7 +213,6 @@ export function XDSRadioList({
stylex.props(
styles.radiogroup,
orientation === 'vertical' ? styles.vertical : styles.horizontal,
- rootOverride,
),
)}>
<RadioListContext.Provider value={contextValue}>
diff --git a/packages/core/src/Section/XDSSection.tsx b/packages/core/src/Section/XDSSection.tsx
index 62adbf0825..1fd00429b0 100644
--- a/packages/core/src/Section/XDSSection.tsx
+++ b/packages/core/src/Section/XDSSection.tsx
@@ -1,6 +1,6 @@
/**
* @file XDSSection.tsx
- * @input Uses container utility, StyleX, ThemeContext
+ * @input Uses container utility, StyleX
* @output Exports XDSSection component and XDSSectionProps
* @position Core section container component
*
@@ -12,11 +12,9 @@
'use client';
-import {forwardRef, useContext, type ReactNode} from 'react';
+import {forwardRef, type ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import {colorVars} from '../theme/tokens.stylex';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
import {container} from '../Layout/container.stylex';
import type {SizeValue} from '../utils/types';
import {xdsClassName, mergeProps} from '../utils';
@@ -26,23 +24,6 @@ import {xdsClassName, mergeProps} from '../utils';
*/
export type XDSSectionVariant = 'section' | 'transparent' | 'wash';
-// =============================================================================
-// Module Augmentation - Register XDSSection's themeable properties
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- section?: {
- /** Outer container styles (positioning, margins) */
- container?: ThemeStyleXStyles;
- /** Inner content styles (padding) */
- content?: ThemeStyleXStyles;
- /** Style overrides for each variant (background, visual styling) */
- variants?: Partial<Record<XDSSectionVariant, ThemeStyleXStyles>>;
- };
- }
-}
-
const variantStyles = stylex.create({
section: {
backgroundColor: colorVars['--color-surface'],
@@ -215,14 +196,6 @@ export const XDSSection = forwardRef<HTMLDivElement, XDSSectionProps>(
},
ref,
) {
- // Get theme context for component-level overrides
- const themeContext = useContext(ThemeContext);
- const containerOverride =
- themeContext?.theme.components?.section?.container;
- const contentOverride = themeContext?.theme.components?.section?.content;
- const variantOverride =
- themeContext?.theme.components?.section?.variants?.[variant];
-
return (
<div
ref={ref}
@@ -236,7 +209,6 @@ export const XDSSection = forwardRef<HTMLDivElement, XDSSectionProps>(
maxWidth ?? null,
minHeight ?? null,
),
- containerOverride,
),
)}
{...props}>
@@ -250,13 +222,11 @@ export const XDSSection = forwardRef<HTMLDivElement, XDSSectionProps>(
paddingOuterY: 'spacing4',
}),
variantStyles[variant],
- variantOverride,
isFullBleed && nestedStyles.fullBleed,
dividers?.includes('top') && dividerStyles.top,
dividers?.includes('bottom') && dividerStyles.bottom,
dividers?.includes('start') && dividerStyles.start,
dividers?.includes('end') && dividerStyles.end,
- contentOverride,
)}>
{children}
</div>
diff --git a/packages/core/src/Selector/XDSSelector.tsx b/packages/core/src/Selector/XDSSelector.tsx
index 409108d38a..0680849cd6 100644
--- a/packages/core/src/Selector/XDSSelector.tsx
+++ b/packages/core/src/Selector/XDSSelector.tsx
@@ -53,8 +53,6 @@ import {
} from './utils';
import {useCombobox, useSelectedItemOffset} from './hooks';
import {XDSSelectorOption} from './XDSSelectorOption';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
import {xdsClassName, mergeProps} from '../utils';
const styles = stylex.create({
@@ -245,20 +243,6 @@ export interface XDSSelectorStatus {
message?: string;
}
-// =============================================================================
-// Module Augmentation - Register component styles with ComponentStyles
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- selector?: {
- /** Trigger button styles */
- trigger?: ThemeStyleXStyles;
- /** Dropdown container styles */
- dropdown?: ThemeStyleXStyles;
- };
- }
-}
export interface XDSSelectorProps<
T extends XDSSelectorOptionType = XDSSelectorOptionType,
> {
@@ -406,10 +390,6 @@ export function XDSSelector<T extends XDSSelectorOptionType>({
children,
'data-testid': testId,
}: XDSSelectorProps<T>) {
- const themeContext = React.useContext(ThemeContext);
- const triggerOverride = themeContext?.theme.components?.selector?.trigger;
- const dropdownOverride = themeContext?.theme.components?.selector?.dropdown;
-
const triggerId = useId();
const listboxId = useId();
const descriptionId = useId();
@@ -632,7 +612,6 @@ export function XDSSelector<T extends XDSSelectorOptionType>({
!selectedItem && styles.triggerPlaceholder,
status && inputStatusBorderStyles[status.type],
status && inputStatusHoverShadowStyles[status.type],
- triggerOverride,
),
)}>
<span>{selectedItem?.label ?? placeholder}</span>
@@ -665,7 +644,6 @@ export function XDSSelector<T extends XDSSelectorOptionType>({
styles.dropdown,
!isPositioned && styles.dropdownHidden,
styles.dropdownOffset(-selectedItemOffset),
- dropdownOverride,
)}>
{renderOptions()}
</div>,
diff --git a/packages/core/src/SideNav/XDSSideNav.tsx b/packages/core/src/SideNav/XDSSideNav.tsx
index b1f07d0982..e883e442c1 100644
--- a/packages/core/src/SideNav/XDSSideNav.tsx
+++ b/packages/core/src/SideNav/XDSSideNav.tsx
@@ -16,17 +16,10 @@
'use client';
-import {
- forwardRef,
- useContext,
- type HTMLAttributes,
- type ReactNode,
-} from 'react';
+import {forwardRef, type HTMLAttributes, type ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import type {StyleXStyles} from '@stylexjs/stylex';
import {colorVars, spacingVars} from '../theme/tokens.stylex';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
import {xdsClassName, mergeProps} from '../utils';
// =============================================================================
@@ -83,19 +76,6 @@ const styles = stylex.create({
},
});
-// =============================================================================
-// Module Augmentation
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- sideNav?: {
- /** Root container styles */
- root?: ThemeStyleXStyles;
- };
- }
-}
-
// =============================================================================
// Types
// =============================================================================
@@ -171,9 +151,6 @@ export const XDSSideNav = forwardRef<HTMLElement, XDSSideNavProps>(
},
ref,
) {
- const themeContext = useContext(ThemeContext);
- const rootOverride = themeContext?.theme.components?.sideNav?.root;
-
const hasStickyTop = !!(header || topContent);
const hasStickyBottom = !!(footer || footerIcons);
@@ -185,7 +162,7 @@ export const XDSSideNav = forwardRef<HTMLElement, XDSSideNavProps>(
data-testid={testId}
{...mergeProps(
xdsClassName('side-nav'),
- stylex.props(styles.root, rootOverride, xstyle),
+ stylex.props(styles.root, xstyle),
)}
{...props}>
{hasStickyTop && (
diff --git a/packages/core/src/Skeleton/XDSSkeleton.tsx b/packages/core/src/Skeleton/XDSSkeleton.tsx
index 36a67fdeee..065c7151fe 100644
--- a/packages/core/src/Skeleton/XDSSkeleton.tsx
+++ b/packages/core/src/Skeleton/XDSSkeleton.tsx
@@ -12,11 +12,9 @@
'use client';
-import {forwardRef, useContext, type HTMLAttributes} from 'react';
+import {forwardRef, type HTMLAttributes} from 'react';
import * as stylex from '@stylexjs/stylex';
import {colorVars, radiusVars} from '../theme/tokens.stylex';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
import {xdsClassName, mergeProps} from '../utils';
// =============================================================================
@@ -113,18 +111,6 @@ export type XDSSkeletonRadius = keyof typeof radiusStyles;
// Component
// =============================================================================
-// =============================================================================
-// Module Augmentation - Register component styles with ComponentStyles
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- skeleton?: {
- /** Root skeleton styles */
- root?: ThemeStyleXStyles;
- };
- }
-}
export interface XDSSkeletonProps extends Omit<
HTMLAttributes<HTMLDivElement>,
'className' | 'style'
@@ -190,8 +176,6 @@ export const XDSSkeleton = forwardRef<HTMLDivElement, XDSSkeletonProps>(
},
ref,
) => {
- const themeContext = useContext(ThemeContext);
- const rootOverride = themeContext?.theme.components?.skeleton?.root;
return (
<div
ref={ref}
@@ -204,7 +188,6 @@ export const XDSSkeleton = forwardRef<HTMLDivElement, XDSSkeletonProps>(
radiusStyles[radiusProp],
dynamicStyles.dimensions(width, height),
dynamicStyles.animationDelay(index),
- rootOverride,
),
)}
{...props}
diff --git a/packages/core/src/Slider/XDSSlider.tsx b/packages/core/src/Slider/XDSSlider.tsx
index a456a19bb7..053255978c 100644
--- a/packages/core/src/Slider/XDSSlider.tsx
+++ b/packages/core/src/Slider/XDSSlider.tsx
@@ -15,7 +15,6 @@
import {
forwardRef,
- useContext,
useId,
useRef,
useCallback,
@@ -35,31 +34,11 @@ import {
import {XDSField} from '../Field/XDSField';
import {XDSTooltip} from '../Layer/XDSTooltip';
import type {XDSInputStatus} from '../Field/types';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
// =============================================================================
// Types
// =============================================================================
-// =============================================================================
-// Module Augmentation - Register component styles with ComponentStyles
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- slider?: {
- /** Root container styles */
- root?: ThemeStyleXStyles;
- /** Track styles */
- track?: ThemeStyleXStyles;
- /** Filled track styles */
- filledTrack?: ThemeStyleXStyles;
- /** Thumb styles */
- thumb?: ThemeStyleXStyles;
- };
- }
-}
export interface XDSSliderBaseProps {
/** Label text for the slider (always rendered for accessibility). */
label: string;
@@ -347,13 +326,6 @@ export const XDSSlider = forwardRef<HTMLDivElement, XDSSliderProps>(
onChangeEnd,
} = props;
- const themeContext = useContext(ThemeContext);
- const rootOverride = themeContext?.theme.components?.slider?.root;
- const trackOverride = themeContext?.theme.components?.slider?.track;
- const filledTrackOverride =
- themeContext?.theme.components?.slider?.filledTrack;
- const thumbOverride = themeContext?.theme.components?.slider?.thumb;
-
const isRange = Array.isArray(value);
const minStepsBetweenThumbs =
isRange && 'minStepsBetweenThumbs' in props
@@ -589,7 +561,6 @@ export const XDSSlider = forwardRef<HTMLDivElement, XDSSliderProps>(
!isDisabled && styles.thumbHover,
!isDisabled && styles.thumbFocusWithin,
isDisabled && styles.thumbDisabled,
- thumbOverride,
)}
/>
);
@@ -660,7 +631,7 @@ export const XDSSlider = forwardRef<HTMLDivElement, XDSSliderProps>(
labelTooltip={labelTooltip}
statusVariant="detached"
{...stylex.props(xstyle)}>
- <div {...stylex.props(styles.sliderRow, rootOverride)}>
+ <div {...stylex.props(styles.sliderRow)}>
<div
ref={node => {
// Merge refs
@@ -689,7 +660,6 @@ export const XDSSlider = forwardRef<HTMLDivElement, XDSSliderProps>(
{...stylex.props(
styles.track,
isHorizontal ? styles.trackHorizontal : styles.trackVertical,
- trackOverride,
)}
/>
@@ -701,7 +671,6 @@ export const XDSSlider = forwardRef<HTMLDivElement, XDSSliderProps>(
isHorizontal
? styles.filledTrackHorizontal
: styles.filledTrackVertical,
- filledTrackOverride,
)}
/>
diff --git a/packages/core/src/Spinner/XDSSpinner.tsx b/packages/core/src/Spinner/XDSSpinner.tsx
index ad5eb87121..531e9815fe 100644
--- a/packages/core/src/Spinner/XDSSpinner.tsx
+++ b/packages/core/src/Spinner/XDSSpinner.tsx
@@ -13,11 +13,9 @@
'use client';
-import {forwardRef, useContext, useEffect, useRef} from 'react';
+import {forwardRef, useEffect, useRef} from 'react';
import * as stylex from '@stylexjs/stylex';
import {colorVars} from '../theme/tokens.stylex';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
import {xdsClassName, mergeProps} from '../utils';
// =============================================================================
@@ -69,20 +67,9 @@ const styles = stylex.create({
// =============================================================================
export type XDSSpinnerSize = keyof typeof SIZES;
-export type XDSSpinnerShade = 'default' | 'onMedia';
-// =============================================================================
-// Module Augmentation - Register component styles with ComponentStyles
-// =============================================================================
+export type XDSSpinnerShade = 'default' | 'onMedia';
-declare module '../theme/types' {
- interface ComponentStyles {
- spinner?: {
- /** Root spinner styles */
- root?: ThemeStyleXStyles;
- };
- }
-}
export interface XDSSpinnerProps {
/**
* Spinner size.
@@ -120,8 +107,6 @@ export interface XDSSpinnerProps {
*/
export const XDSSpinner = forwardRef<HTMLSpanElement, XDSSpinnerProps>(
({size = 'md', shade = 'default', 'data-testid': testId}, ref) => {
- const themeContext = useContext(ThemeContext);
- const rootOverride = themeContext?.theme.components?.spinner?.root;
const canvasRef = useRef<HTMLCanvasElement>(null);
useEffect(() => {
@@ -188,7 +173,7 @@ export const XDSSpinner = forwardRef<HTMLSpanElement, XDSSpinnerProps>(
data-testid={testId}
{...mergeProps(
xdsClassName('spinner', {size}),
- stylex.props(styles.spinner, rootOverride),
+ stylex.props(styles.spinner),
)}
style={{width: frameSize, height: frameSize}}>
<canvas ref={canvasRef} {...stylex.props(styles.canvas)} />
diff --git a/packages/core/src/Switch/XDSSwitch.tsx b/packages/core/src/Switch/XDSSwitch.tsx
index 2cada3d027..47e3f30b54 100644
--- a/packages/core/src/Switch/XDSSwitch.tsx
+++ b/packages/core/src/Switch/XDSSwitch.tsx
@@ -15,7 +15,6 @@
import {
forwardRef,
- useContext,
useId,
useOptimistic,
useTransition,
@@ -35,8 +34,6 @@ import {XDSFieldLabel} from '../Field/XDSFieldLabel';
import {XDSFieldStatus} from '../Field/XDSFieldStatus';
import type {XDSIconType} from '../Icon';
import type {XDSInputStatus} from '../Field/types';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
import {XDSSpinner} from '../Spinner';
import {xdsClassName, mergeProps} from '../utils';
@@ -154,24 +151,9 @@ const styles = stylex.create({
});
export type XDSSwitchLabelPosition = 'start' | 'end';
-export type XDSSwitchLabelSpacing = 'default' | 'spread';
-// =============================================================================
-// Module Augmentation - Register component styles with ComponentStyles
-// =============================================================================
+export type XDSSwitchLabelSpacing = 'default' | 'spread';
-declare module '../theme/types' {
- interface ComponentStyles {
- switch?: {
- /** Root container styles */
- root?: ThemeStyleXStyles;
- /** Track styles */
- track?: ThemeStyleXStyles;
- /** Thumb styles */
- thumb?: ThemeStyleXStyles;
- };
- }
-}
export interface XDSSwitchProps {
/**
* Label text for the switch (always rendered for accessibility).
@@ -299,11 +281,6 @@ export const XDSSwitch = forwardRef<HTMLInputElement, XDSSwitchProps>(
},
ref,
) => {
- const themeContext = useContext(ThemeContext);
- const rootOverride = themeContext?.theme.components?.switch?.root;
- const trackOverride = themeContext?.theme.components?.switch?.track;
- const thumbOverride = themeContext?.theme.components?.switch?.thumb;
-
const id = useId();
const descriptionID = useId();
const statusMessageID = useId();
@@ -357,14 +334,12 @@ export const XDSSwitch = forwardRef<HTMLInputElement, XDSSwitchProps>(
isOn ? styles.trackOn : styles.trackOff,
isDisabled && styles.trackDisabled,
isDisabled && !isOn && styles.trackDisabledOff,
- trackOverride,
),
)}>
<div
{...stylex.props(
styles.thumb,
isOn ? styles.thumbOn : styles.thumbOff,
- thumbOverride,
)}
style={{
display: 'flex',
@@ -403,7 +378,6 @@ export const XDSSwitch = forwardRef<HTMLInputElement, XDSSwitchProps>(
{...stylex.props(
styles.container,
labelSpacing === 'spread' && styles.containerSpread,
- rootOverride,
!isDisabled && stylex.defaultMarker(),
)}>
{labelPosition === 'start' ? (
diff --git a/packages/core/src/TabList/XDSTabList.tsx b/packages/core/src/TabList/XDSTabList.tsx
index 9e5f04f336..f7593cfe0e 100644
--- a/packages/core/src/TabList/XDSTabList.tsx
+++ b/packages/core/src/TabList/XDSTabList.tsx
@@ -12,27 +12,13 @@
'use client';
-import {useContext, useMemo, type ReactNode} from 'react';
+import {useMemo, type ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import {colorVars, spacingVars} from '../theme/tokens.stylex';
import {XDSTabListContext} from './XDSTabListContext';
import type {XDSTabListSize} from './XDSTabListContext';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
import {xdsClassName, mergeProps} from '../utils';
-// =============================================================================
-// Module Augmentation - Register component styles with ComponentStyles
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- tabList?: {
- /** Root nav container styles */
- root?: ThemeStyleXStyles;
- };
- }
-}
export interface XDSTabListProps {
/**
* The currently selected tab value.
@@ -94,9 +80,6 @@ export function XDSTabList({
hasDivider = false,
children,
}: XDSTabListProps) {
- const themeContext = useContext(ThemeContext);
- const rootOverride = themeContext?.theme.components?.tabList?.root;
-
const contextValue = useMemo(
() => ({value, onChange, size}),
[value, onChange, size],
@@ -108,7 +91,7 @@ export function XDSTabList({
aria-label="Tabs"
{...mergeProps(
xdsClassName('tab-list', {size}),
- stylex.props(styles.nav, hasDivider && styles.divider, rootOverride),
+ stylex.props(styles.nav, hasDivider && styles.divider),
)}>
{children}
</nav>
diff --git a/packages/core/src/Table/XDSTable.tsx b/packages/core/src/Table/XDSTable.tsx
index 4370627995..6342d6bd45 100644
--- a/packages/core/src/Table/XDSTable.tsx
+++ b/packages/core/src/Table/XDSTable.tsx
@@ -13,13 +13,7 @@
'use client';
-import {
- forwardRef,
- useContext,
- useMemo,
- type ReactElement,
- type Ref,
-} from 'react';
+import {forwardRef, useMemo, type ReactElement, type Ref} from 'react';
import * as stylex from '@stylexjs/stylex';
import {colorVars} from '../theme/tokens.stylex';
import {XDSBaseTable} from './XDSBaseTable';
@@ -29,17 +23,17 @@ import {XDSTableHeaderCell} from './XDSTableHeaderCell';
import {XDSTableContext} from './XDSTableContext';
import {useXDSBaseTablePlugins} from './useXDSBaseTablePlugins';
import type {XDSBaseTableProps, TablePlugin, TableRenderProps} from './types';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
// =============================================================================
// XDSTable Types
// =============================================================================
/** Row density controlling padding and font size */
+
export type XDSTableDensity = 'compact' | 'balanced' | 'spacious';
/** Divider style between cells */
+
export type XDSTableDividers = 'rows' | 'columns' | 'grid' | 'none';
/**
@@ -49,26 +43,6 @@ export type XDSTableDividers = 'rows' | 'columns' | 'grid' | 'none';
* @template T - The row data type
*/
-// =============================================================================
-// Module Augmentation - Register component styles with ComponentStyles
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- table?: {
- /** Root table styles */
- root?: ThemeStyleXStyles;
- /** Header row styles */
- headerRow?: ThemeStyleXStyles;
- /** Body row styles */
- bodyRow?: ThemeStyleXStyles;
- /** Header cell styles */
- headerCell?: ThemeStyleXStyles;
- /** Body cell styles */
- bodyCell?: ThemeStyleXStyles;
- };
- }
-}
export interface XDSTableProps<T extends Record<string, unknown>> extends Omit<
XDSBaseTableProps<T>,
'plugins' | 'components'
@@ -100,18 +74,14 @@ const tableStyles = stylex.create({
// Table-level styling plugin (only transforms the <table> element)
// =============================================================================
-function buildTableStylePlugin<T extends Record<string, unknown>>(
- rootOverride?: ThemeStyleXStyles,
-): TablePlugin<T> {
+function buildTableStylePlugin<
+ T extends Record<string, unknown>,
+>(): TablePlugin<T> {
return {
transformTable(props: TableRenderProps): TableRenderProps {
return {
...props,
- styles: [
- ...props.styles,
- tableStyles.base,
- ...(rootOverride ? [rootOverride] : []),
- ],
+ styles: [...props.styles, tableStyles.base],
};
},
};
@@ -141,15 +111,8 @@ function XDSTableInner<T extends Record<string, unknown>>(
}: XDSTableProps<T>,
ref: Ref<HTMLTableElement>,
): ReactElement {
- // Get theme context for component-level overrides
- const themeContext = useContext(ThemeContext);
- const rootOverride = themeContext?.theme.components?.table?.root;
-
// Table-level styling plugin (just adds font/color to <table>)
- const tablePlugin = useMemo(
- () => buildTableStylePlugin<T>(rootOverride),
- [rootOverride],
- );
+ const tablePlugin = useMemo(() => buildTableStylePlugin<T>(), []);
const basePlugins = useMemo(() => [tablePlugin], [tablePlugin]);
// Convert named plugin record to stable memoized array
diff --git a/packages/core/src/Text/XDSFontWrapper.tsx b/packages/core/src/Text/XDSFontWrapper.tsx
index aa81704412..661e1dde13 100644
--- a/packages/core/src/Text/XDSFontWrapper.tsx
+++ b/packages/core/src/Text/XDSFontWrapper.tsx
@@ -1,6 +1,6 @@
/**
* @file XDSFontWrapper.tsx
- * @input Uses React, StyleX, Theme, reset.css
+ * @input Uses React, reset.css
* @output Exports XDSFontWrapper component
* @position Typography component; provides base styles for wrapped content
*
@@ -10,8 +10,6 @@
*/
import * as React from 'react';
-import * as stylex from '@stylexjs/stylex';
-import {useTheme} from '../theme/XDSTheme';
import '../typography.css';
/**
@@ -76,22 +74,14 @@ export function XDSFontWrapper({
children,
'data-testid': testId,
}: XDSFontWrapperProps): React.ReactElement {
- const themeContext = useTheme();
- const proseBase = themeContext?.theme.components?.prose?.base;
-
- // Combine StyleX base styles with CSS typography class
+ // Combine CSS typography class for prose styling
const typographyClass =
variant === 'editorial'
? 'xds-typography xds-typography--editorial'
: 'xds-typography xds-typography--default';
- const stylexProps = stylex.props(proseBase);
-
return (
- <div
- className={`${typographyClass} ${stylexProps.className ?? ''}`.trim()}
- style={stylexProps.style}
- data-testid={testId}>
+ <div className={typographyClass} data-testid={testId}>
{children}
</div>
);
@@ -101,28 +91,15 @@ XDSFontWrapper.displayName = 'XDSFontWrapper';
/**
* Hook to access font wrapper styles from the current theme.
- * Use this for applying styles to native HTML elements programmatically.
*
- * @example
- * ```
- * const { headingStyles, proseStyles } = useXDSFontWrapperStyles();
- *
- * <h1 {...stylex.props(headingStyles?.h1)}>Title</h1>
- * <p {...stylex.props(proseStyles?.p)}>Paragraph</p>
- * ```
+ * @deprecated Theme component styles are now applied via CSS classes.
+ * Use the `.xds-typography` class instead of reading styles from context.
*/
export function useXDSFontWrapperStyles() {
- const themeContext = useTheme();
- const theme = themeContext?.theme;
-
return {
- /** Base wrapper styles */
- base: theme?.components?.prose?.base,
- /** Default heading styles (h1-h6) */
- headingStyles: theme?.components?.heading?.styles,
- /** Editorial heading styles (h1-h6, larger scale) */
- editorialHeadingStyles: theme?.components?.heading?.editorialStyles,
- /** Prose element styles (p, ul, ol, li, blockquote, code, pre, hr, etc.) */
- proseStyles: theme?.components?.prose?.styles,
+ base: undefined,
+ headingStyles: undefined,
+ editorialHeadingStyles: undefined,
+ proseStyles: undefined,
};
}
diff --git a/packages/core/src/Text/XDSHeading.tsx b/packages/core/src/Text/XDSHeading.tsx
index 92a8f34f7e..3f647e53b1 100644
--- a/packages/core/src/Text/XDSHeading.tsx
+++ b/packages/core/src/Text/XDSHeading.tsx
@@ -18,15 +18,12 @@ import {
lazy,
Suspense,
useCallback,
- useContext,
useRef,
type ReactNode,
} from 'react';
import * as stylex from '@stylexjs/stylex';
import type {StyleXStyles} from '@stylexjs/stylex';
-import {ThemeContext} from '../theme/ThemeContext';
import type {
- HeadingLevel,
XDSTextColor,
XDSTextDisplay,
XDSWordBreak,
@@ -168,15 +165,6 @@ const levelToTag = {
6: 'h6',
} as const;
-const levelToKey: Record<XDSHeadingLevel, HeadingLevel> = {
- 1: 'h1',
- 2: 'h2',
- 3: 'h3',
- 4: 'h4',
- 5: 'h5',
- 6: 'h6',
-};
-
/**
* XDSHeading - Semantic heading component
*
@@ -216,16 +204,7 @@ export const XDSHeading = forwardRef<HTMLHeadingElement, XDSHeadingProps>(
},
forwardedRef,
) {
- const themeContext = useContext(ThemeContext);
const Component = levelToTag[level];
- const levelKey = levelToKey[level];
-
- const headingConfig = themeContext?.theme?.components?.heading;
- const headingStyles =
- variant === 'editorial'
- ? headingConfig?.editorialStyles
- : headingConfig?.styles;
- const levelStyle = headingStyles?.[levelKey];
// If accessibilityLevel differs from visual level, use aria-level
const ariaProps =
@@ -281,7 +260,6 @@ export const XDSHeading = forwardRef<HTMLHeadingElement, XDSHeadingProps>(
{...mergeProps(
xdsClassName('heading', {variant, level}),
stylex.props(
- levelStyle,
colorStyles[color],
// Display: use truncation styles when maxLines > 0
maxLines === 1
diff --git a/packages/core/src/Text/XDSText.tsx b/packages/core/src/Text/XDSText.tsx
index 990a6a006a..cad4f8973b 100644
--- a/packages/core/src/Text/XDSText.tsx
+++ b/packages/core/src/Text/XDSText.tsx
@@ -18,13 +18,11 @@ import {
lazy,
Suspense,
useCallback,
- useContext,
useRef,
type ReactNode,
} from 'react';
import * as stylex from '@stylexjs/stylex';
import type {StyleXStyles} from '@stylexjs/stylex';
-import {ThemeContext} from '../theme/ThemeContext';
import type {
XDSTextType,
XDSTextSize,
@@ -203,10 +201,6 @@ export const XDSText = forwardRef<HTMLElement, XDSTextProps>(function XDSText(
},
forwardedRef,
) {
- const themeContext = useContext(ThemeContext);
- const textStyles = themeContext?.theme?.components?.text?.styles;
- const typeStyle = textStyles?.[type];
-
// Resolve color with type-based default
const resolvedColor = color ?? defaultColorByType[type];
@@ -256,7 +250,6 @@ export const XDSText = forwardRef<HTMLElement, XDSTextProps>(function XDSText(
{...mergeProps(
xdsClassName('text', {type}),
stylex.props(
- typeStyle,
colorStyles[resolvedColor],
weight && weightStyles[weight],
// Display: use truncation styles when maxLines > 0
diff --git a/packages/core/src/TextArea/XDSTextArea.tsx b/packages/core/src/TextArea/XDSTextArea.tsx
index a7d7d96fe5..64594b885b 100644
--- a/packages/core/src/TextArea/XDSTextArea.tsx
+++ b/packages/core/src/TextArea/XDSTextArea.tsx
@@ -15,7 +15,6 @@
import {
forwardRef,
- useContext,
useId,
useOptimistic,
useTransition,
@@ -40,8 +39,6 @@ import {
} from '../Field';
import {XDSIcon, type XDSIconType} from '../Icon';
import {XDSSpinner} from '../Spinner';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
const styles = stylex.create({
wrapper: {
@@ -97,20 +94,6 @@ export interface XDSTextAreaStatus {
message?: string;
}
-// =============================================================================
-// Module Augmentation - Register component styles with ComponentStyles
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- textArea?: {
- /** Wrapper container styles */
- wrapper?: ThemeStyleXStyles;
- /** Textarea element styles */
- textarea?: ThemeStyleXStyles;
- };
- }
-}
export interface XDSTextAreaProps {
/**
* Label text for the textarea (always rendered for accessibility).
@@ -240,10 +223,6 @@ export const XDSTextArea = forwardRef<HTMLTextAreaElement, XDSTextAreaProps>(
},
ref,
) => {
- const themeContext = useContext(ThemeContext);
- const wrapperOverride = themeContext?.theme.components?.textArea?.wrapper;
- const textareaOverride = themeContext?.theme.components?.textArea?.textarea;
-
const id = useId();
const descriptionID = useId();
const statusMessageID = useId();
@@ -313,7 +292,6 @@ export const XDSTextArea = forwardRef<HTMLTextAreaElement, XDSTextAreaProps>(
status && inputStatusBorderStyles[status.type],
status && inputStatusHoverShadowStyles[status.type],
status && inputStatusFocusWithinStyles[status.type],
- wrapperOverride,
)}>
{startIcon && <XDSIcon icon={startIcon} size="sm" color="primary" />}
<textarea
@@ -336,7 +314,6 @@ export const XDSTextArea = forwardRef<HTMLTextAreaElement, XDSTextAreaProps>(
{...stylex.props(
styles.textarea,
isDisabled && styles.textareaDisabled,
- textareaOverride,
)}
/>
{isBusy && <XDSSpinner size="sm" />}
diff --git a/packages/core/src/TextInput/XDSTextInput.tsx b/packages/core/src/TextInput/XDSTextInput.tsx
index 1977daaba2..c2230b3ea7 100644
--- a/packages/core/src/TextInput/XDSTextInput.tsx
+++ b/packages/core/src/TextInput/XDSTextInput.tsx
@@ -15,7 +15,6 @@
import {
forwardRef,
- useContext,
useId,
useOptimistic,
useTransition,
@@ -83,28 +82,13 @@ const sizeStyles = stylex.create({
export type XDSTextInputSize = keyof typeof sizeStyles;
// Re-export shared types for convenience
+
export type {
XDSInputStatus as XDSTextInputStatus,
XDSInputStatusType as XDSTextInputStatusType,
} from '../Field';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
import {xdsClassName, mergeProps} from '../utils';
-// =============================================================================
-// Module Augmentation - Register component styles with ComponentStyles
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- textInput?: {
- /** Wrapper container styles */
- wrapper?: ThemeStyleXStyles;
- /** Input element styles */
- input?: ThemeStyleXStyles;
- };
- }
-}
export interface XDSTextInputProps {
/**
* Label text for the input (always rendered for accessibility).
@@ -219,10 +203,6 @@ export const XDSTextInput = forwardRef<HTMLInputElement, XDSTextInputProps>(
},
ref,
) => {
- const themeContext = useContext(ThemeContext);
- const wrapperOverride = themeContext?.theme.components?.textInput?.wrapper;
- const inputOverride = themeContext?.theme.components?.textInput?.input;
-
const id = useId();
const descriptionID = useId();
const statusMessageID = useId();
@@ -295,7 +275,6 @@ export const XDSTextInput = forwardRef<HTMLInputElement, XDSTextInputProps>(
status && inputStatusBorderStyles[status.type],
status && inputStatusHoverShadowStyles[status.type],
status && inputStatusFocusWithinStyles[status.type],
- wrapperOverride,
),
)}>
{startIcon && <XDSIcon icon={startIcon} size="sm" color="primary" />}
@@ -313,11 +292,7 @@ export const XDSTextInput = forwardRef<HTMLInputElement, XDSTextInputProps>(
aria-required={isRequired === true ? 'true' : undefined}
aria-invalid={status?.type === 'error' ? 'true' : undefined}
aria-busy={isBusy || undefined}
- {...stylex.props(
- styles.input,
- isDisabled && styles.inputDisabled,
- inputOverride,
- )}
+ {...stylex.props(styles.input, isDisabled && styles.inputDisabled)}
/>
{isBusy && <XDSSpinner size="sm" />}
{status && (
diff --git a/packages/core/src/TimeInput/XDSTimeInput.tsx b/packages/core/src/TimeInput/XDSTimeInput.tsx
index c0c0250bfd..2c7b0cc509 100644
--- a/packages/core/src/TimeInput/XDSTimeInput.tsx
+++ b/packages/core/src/TimeInput/XDSTimeInput.tsx
@@ -15,7 +15,6 @@
import {
forwardRef,
- useContext,
useId,
useState,
useCallback,
@@ -119,30 +118,16 @@ const sizeStyles = stylex.create({
});
export type XDSTimeInputSize = keyof typeof sizeStyles;
+
export type XDSTimeInputHourFormat = '12h' | '24h';
// Re-export shared types for convenience
+
export type {
XDSInputStatus as XDSTimeInputStatus,
XDSInputStatusType as XDSTimeInputStatusType,
} from '../Field';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
-
-// =============================================================================
-// Module Augmentation - Register component styles with ComponentStyles
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- timeInput?: {
- /** Input wrapper styles */
- wrapper?: ThemeStyleXStyles;
- /** Text input styles */
- input?: ThemeStyleXStyles;
- };
- }
-}
+
export interface XDSTimeInputProps {
/**
* Label text for the input (required for accessibility).
@@ -303,10 +288,6 @@ export const XDSTimeInput = forwardRef<HTMLInputElement, XDSTimeInputProps>(
},
ref,
) => {
- const themeContext = useContext(ThemeContext);
- const wrapperOverride = themeContext?.theme.components?.timeInput?.wrapper;
- const inputOverride = themeContext?.theme.components?.timeInput?.input;
-
const id = useId();
const descriptionID = useId();
const statusMessageID = useId();
@@ -523,7 +504,6 @@ export const XDSTimeInput = forwardRef<HTMLInputElement, XDSTimeInputProps>(
status && inputStatusBorderStyles[status.type],
status && inputStatusHoverShadowStyles[status.type],
status && inputStatusFocusWithinStyles[status.type],
- wrapperOverride,
)}>
<div {...stylex.props(styles.icon)}>
<XDSIcon icon="clock" size="sm" color="secondary" />
@@ -547,7 +527,6 @@ export const XDSTimeInput = forwardRef<HTMLInputElement, XDSTimeInputProps>(
styles.input,
isDisabled && styles.inputDisabled,
!isInputValid && styles.inputInvalid,
- inputOverride,
)}
/>
{isBusy && <XDSSpinner size="sm" />}
diff --git a/packages/core/src/TopNav/XDSTopNav.tsx b/packages/core/src/TopNav/XDSTopNav.tsx
index 46dfd1d9b8..815c4b01c0 100644
--- a/packages/core/src/TopNav/XDSTopNav.tsx
+++ b/packages/core/src/TopNav/XDSTopNav.tsx
@@ -13,16 +13,9 @@
'use client';
-import {
- forwardRef,
- useContext,
- type HTMLAttributes,
- type ReactNode,
-} from 'react';
+import {forwardRef, type HTMLAttributes, type ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import {colorVars, spacingVars} from '../theme/tokens.stylex';
-import {ThemeContext} from '../theme/ThemeContext';
-import type {StyleXStyles as ThemeStyleXStyles} from '../theme/types';
import {edgeSignals} from '../Layout/edgeCompensation.stylex';
import {xdsClassName, mergeProps} from '../utils';
@@ -89,18 +82,6 @@ const styles = stylex.create({
},
});
-// =============================================================================
-// Module Augmentation - Register component styles with ComponentStyles
-// =============================================================================
-
-declare module '../theme/types' {
- interface ComponentStyles {
- topNav?: {
- /** Root nav bar styles */
- root?: ThemeStyleXStyles;
- };
- }
-}
export interface XDSTopNavProps extends Omit<
HTMLAttributes<HTMLElement>,
'style' | 'className' | 'title'
@@ -156,8 +137,6 @@ export const XDSTopNav = forwardRef<HTMLElement, XDSTopNavProps>(
{title, startContent, centerContent, endContent, label, ...props},
ref,
) {
- const themeContext = useContext(ThemeContext);
- const rootOverride = themeContext?.theme.components?.topNav?.root;
const hasCenterContent = centerContent != null;
return (
@@ -170,7 +149,6 @@ export const XDSTopNav = forwardRef<HTMLElement, XDSTopNavProps>(
stylex.props(
styles.base,
hasCenterContent ? styles.baseGrid : styles.baseFlex,
- rootOverride,
),
)}
{...props}>
diff --git a/packages/core/src/theme/ThemeContext.ts b/packages/core/src/theme/ThemeContext.ts
deleted file mode 100644
index 1b48c9042c..0000000000
--- a/packages/core/src/theme/ThemeContext.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * Theme Context
- *
- * Separated from Theme.tsx to allow components to consume theme
- * without pulling in the full theme provider implementation.
- */
-
-'use client';
-
-import {createContext} from 'react';
-import type {Theme, ThemeMode} from './types';
-
-/**
- * Theme context value
- */
-export interface ThemeContextValue {
- theme: Theme;
- mode: ThemeMode;
-}
-
-/**
- * Theme context - provides theme to components
- * Components use this to access theme-level variant overrides
- */
-export const ThemeContext = createContext<ThemeContextValue | null>(null);
diff --git a/packages/core/src/theme/XDSTheme.tsx b/packages/core/src/theme/XDSTheme.tsx
index a38d0e4ee2..824c85b827 100644
--- a/packages/core/src/theme/XDSTheme.tsx
+++ b/packages/core/src/theme/XDSTheme.tsx
@@ -2,17 +2,12 @@
* XDSTheme Provider Component
*
* Applies theme tokens and sets color-scheme for light-dark() to work.
- * Supports two theme types:
- * - XDSDefinedTheme (from defineTheme): generates CSS or uses pre-built styles
- * - Legacy Theme (StyleX): applies StyleX theme styles directly
- *
- * With defineTheme, components get their overrides via CSS (e.g. .xds-button)
- * scoped under the theme's data-xds-theme attribute — no context reads needed.
- * This unlocks RSC for all components.
+ * Themes are created with `defineTheme()` and applied via CSS:
+ * - Token overrides set as CSS custom properties on [data-xds-theme]
+ * - Component overrides scoped via @scope'd CSS selectors on .xds-* classes
*
* Usage:
* ```tsx
- * // New API — defineTheme
* const ocean = defineTheme({
* name: 'ocean',
* tokens: { '--color-accent': ['#0077B6', '#48CAE4'] },
@@ -23,47 +18,26 @@
*
* // Built theme — CSS imported separately
* import { oceanTheme } from '@xds/theme-ocean';
- * import '@xds/theme-ocean/styles.css';
+ * import '@xds/theme-ocean/theme.css';
* <XDSTheme theme={oceanTheme}><App /></XDSTheme>
- *
- * // Legacy API — StyleX theme object (still supported)
- * <XDSTheme theme={defaultTheme}><App /></XDSTheme>
* ```
*/
'use client';
-import React, {useContext, useMemo, useId, useInsertionEffect} from 'react';
+import React, {useId, useInsertionEffect} from 'react';
import * as stylex from '@stylexjs/stylex';
-import type {Theme as LegacyTheme, ThemeMode} from './types';
-import {ThemeContext, type ThemeContextValue} from './ThemeContext';
+import type {ThemeMode} from './types';
import {colorVars, typographyVars} from './tokens.stylex';
import {IconRegistryContext} from '../Icon/IconRegistry';
-import {
- isDefinedTheme,
- generateThemeCSS,
- type XDSDefinedTheme,
-} from './defineTheme';
-
-// Re-export for backwards compatibility
-export {ThemeContext} from './ThemeContext';
-
-/**
- * Hook to access current theme
- */
-export function useXDSTheme(): ThemeContextValue | null {
- return useContext(ThemeContext);
-}
-
-/** @deprecated Use useXDSTheme instead */
-export const useTheme = useXDSTheme;
+import {generateThemeCSS, type XDSDefinedTheme} from './defineTheme';
/**
* XDSTheme provider props
*/
interface XDSThemeProps {
- /** Theme — from defineTheme() or a legacy StyleX theme object */
- theme: XDSDefinedTheme | LegacyTheme;
+ /** Theme from defineTheme() */
+ theme: XDSDefinedTheme;
/** Color mode - 'system' follows OS preference */
mode?: ThemeMode;
/** Children to render */
@@ -99,32 +73,24 @@ const injectedThemes = new Set<string>();
/**
* Hook to inject theme CSS into the document.
- * Always called (React rules of hooks) but only does work for unbuilt
- * XDSDefinedTheme instances.
+ * Built themes (from `xds build-theme`) skip injection — their CSS
+ * is in a separate file imported by the consumer.
*/
-function useThemeStyleInjection(
- theme: XDSDefinedTheme | LegacyTheme,
- defined: boolean,
-): void {
+function useThemeStyleInjection(theme: XDSDefinedTheme): void {
const id = useId();
useInsertionEffect(() => {
- // Only inject for unbuilt XDSDefinedTheme instances
- if (!defined) return;
-
- const dt = theme as XDSDefinedTheme;
-
// Built themes have their CSS in a separate file — skip injection
- if (dt.__built) return;
+ if (theme.__built) return;
- const themeKey = `xds-theme-${dt.name}`;
+ const themeKey = `xds-theme-${theme.name}`;
if (injectedThemes.has(themeKey)) return;
- const css = generateThemeCSS(dt);
+ const css = generateThemeCSS(theme);
if (!css) return;
const style = document.createElement('style');
- style.setAttribute('data-xds-theme', dt.name);
+ style.setAttribute('data-xds-theme', theme.name);
style.setAttribute('data-xds-id', id);
style.textContent = `@layer xds.theme {\n${css}\n}`;
document.head.appendChild(style);
@@ -132,14 +98,14 @@ function useThemeStyleInjection(
return () => {
const existing = document.querySelector(
- `style[data-xds-theme="${dt.name}"][data-xds-id="${id}"]`,
+ `style[data-xds-theme="${theme.name}"][data-xds-id="${id}"]`,
);
if (existing) {
existing.remove();
injectedThemes.delete(themeKey);
}
};
- }, [theme, defined, id]);
+ }, [theme, id]);
}
// =============================================================================
@@ -149,37 +115,16 @@ function useThemeStyleInjection(
/**
* XDSTheme provider component
*
- * For defineTheme themes: sets data-xds-theme attribute so @scope'd CSS
- * takes effect. Component overrides are pure CSS scoped under the theme
- * attribute — components just render with their .xds-* class and don't
- * need context. This enables RSC for all components.
- *
- * For legacy themes: applies StyleX theme styles via context (existing behavior).
+ * Sets data-xds-theme attribute so @scope'd CSS takes effect.
+ * Component overrides are pure CSS scoped under the theme attribute —
+ * components render with their .xds-* class and don't need context.
*/
export function XDSTheme({
theme,
mode = 'system',
children,
}: XDSThemeProps): React.ReactElement {
- const defined = isDefinedTheme(theme);
-
- // Always call the hook (React rules) — it no-ops for legacy themes
- useThemeStyleInjection(theme, defined);
-
- // Build context value (still needed for legacy themes and useXDSTheme hook)
- const contextValue = useMemo(() => {
- if (defined) {
- const dt = theme as XDSDefinedTheme;
- const legacyTheme: LegacyTheme = {
- name: dt.name,
- styles: {},
- icons: dt.icons,
- raw: {},
- };
- return {theme: legacyTheme, mode};
- }
- return {theme: theme as LegacyTheme, mode};
- }, [theme, mode, defined]);
+ useThemeStyleInjection(theme);
// Get color-scheme style
const colorSchemeStyle =
@@ -189,30 +134,8 @@ export function XDSTheme({
? wrapperStyles.light
: wrapperStyles.system;
- // StyleX props — defined themes only need base + color scheme,
- // legacy themes also apply all token group styles
- const stylexProps = defined
- ? stylex.props(wrapperStyles.base, colorSchemeStyle)
- : stylex.props(
- wrapperStyles.base,
- colorSchemeStyle,
- (theme as LegacyTheme).styles.colors,
- (theme as LegacyTheme).styles.spacing,
- (theme as LegacyTheme).styles.size,
- (theme as LegacyTheme).styles.radius,
- (theme as LegacyTheme).styles.elevation,
- (theme as LegacyTheme).styles.transition,
- (theme as LegacyTheme).styles.typography,
- (theme as LegacyTheme).styles.textSize,
- (theme as LegacyTheme).styles.lineHeight,
- (theme as LegacyTheme).styles.fontWeight,
- );
-
- // Icons — from either theme type
- const icons = defined
- ? (theme as XDSDefinedTheme).icons
- : (theme as LegacyTheme).icons;
-
+ // Icons
+ const icons = theme.icons;
let content: React.ReactNode = children;
if (icons != null) {
content = (
@@ -223,22 +146,13 @@ export function XDSTheme({
}
return (
- <ThemeContext.Provider value={contextValue}>
- <div
- {...stylexProps}
- data-xds-theme={
- defined
- ? (theme as XDSDefinedTheme).name
- : (theme as LegacyTheme).name
- }
- data-theme={mode === 'system' ? undefined : mode}>
- {content}
- </div>
- </ThemeContext.Provider>
+ <div
+ {...stylex.props(wrapperStyles.base, colorSchemeStyle)}
+ data-xds-theme={theme.name}
+ data-theme={mode === 'system' ? undefined : mode}>
+ {content}
+ </div>
);
}
XDSTheme.displayName = 'XDSTheme';
-
-/** @deprecated Use XDSTheme instead */
-export const Theme = XDSTheme;
diff --git a/packages/core/src/theme/index.ts b/packages/core/src/theme/index.ts
index d1653407e5..ae9b8759aa 100644
--- a/packages/core/src/theme/index.ts
+++ b/packages/core/src/theme/index.ts
@@ -3,7 +3,7 @@
*
* Exports:
* - XDSTheme: Provider component that applies theme
- * - useXDSTheme: Hook to access current theme
+ * - defineTheme: Create themes with token + component overrides
* - Token exports for direct use in StyleX
*
* Themes are in separate packages:
@@ -11,7 +11,7 @@
* import { neutralTheme } from '@xds/theme-neutral';
*/
-export {XDSTheme, useXDSTheme, Theme, useTheme} from './XDSTheme';
+export {XDSTheme} from './XDSTheme';
export {
defineTheme,
generateThemeCSS,
@@ -51,20 +51,6 @@ export {
fontWeightVars,
} from './tokens.stylex';
-// Deprecated re-exports — use *Defaults instead
-export {
- colorRaw,
- spacingRaw,
- sizeRaw,
- radiusRaw,
- elevationRaw,
- transitionRaw,
- typographyRaw,
- textSizeRaw,
- lineHeightRaw,
- fontWeightRaw,
-} from './tokens.stylex';
-
// Export token key types for theme authoring
export type {
ColorVarName,
@@ -80,11 +66,7 @@ export type {
} from './tokens.stylex';
export type {
- Theme as ThemeType,
- ThemeRaw,
ThemeMode,
- ComponentStyles,
- ThemeStyles,
HeadingLevel,
XDSTextType,
XDSTextSize,
diff --git a/packages/core/src/theme/types.ts b/packages/core/src/theme/types.ts
index a758507a19..848160852e 100644
--- a/packages/core/src/theme/types.ts
+++ b/packages/core/src/theme/types.ts
@@ -1,9 +1,9 @@
/**
- * XDS Theme Type Definitions
+ * XDS Type Definitions
+ *
+ * Shared types used across XDS components.
*/
-import type {XDSIconRegistry} from '../Icon/IconRegistry';
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type StyleXStyles = any;
@@ -128,110 +128,3 @@ export type ProseElement =
| 'aHover'
| 'firstChild'
| 'lastChild';
-
-/**
- * Component-specific style overrides
- * Each component augments this interface to add its own entry
- * See Button.tsx for an example of module augmentation
- */
-export interface ComponentStyles {
- // Core typography styles
- /** Heading styles (h1-h6) */
- heading?: {
- /** Default heading styles */
- styles?: Partial<Record<HeadingLevel, StyleXStyles>>;
- /** Editorial heading styles (larger scale) */
- editorialStyles?: Partial<Record<HeadingLevel, StyleXStyles>>;
- };
- /** Text styles */
- text?: {
- /** Semantic text styles (body, large, label, supporting, code) */
- styles?: Partial<Record<XDSTextType, StyleXStyles>>;
- };
- /** Prose styles for XDSFontWrapper */
- prose?: {
- /** Base wrapper styles */
- base?: StyleXStyles;
- /** Prose element styles */
- styles?: Partial<Record<ProseElement, StyleXStyles>>;
- };
-
- // Components add their entries via module augmentation
- // Example in Button.tsx:
- // declare module '../theme/types' {
- // interface ComponentStyles {
- // button?: { variants?: Partial<Record<ButtonVariant, StyleXStyles>> };
- // }
- // }
-}
-
-/**
- * Theme styles - StyleX styles that set CSS variables.
- * All fields are optional — omitted groups use the defineVars defaults
- * from tokens.stylex.ts, enabling partial theme overrides.
- *
- * @deprecated Use `defineTheme()` from `@xds/core/theme` instead.
- * StyleX-based themes are being replaced by CSS-based theming.
- */
-export interface ThemeStyles {
- /** Color CSS variables */
- colors?: StyleXStyles;
- /** Spacing CSS variables */
- spacing?: StyleXStyles;
- /** Size CSS variables (component heights: sm, md, lg) */
- size?: StyleXStyles;
- /** Radius CSS variables */
- radius?: StyleXStyles;
- /** Elevation CSS variables */
- elevation?: StyleXStyles;
- /** Transition CSS variables */
- transition?: StyleXStyles;
- /** Typography (font family) CSS variables */
- typography?: StyleXStyles;
- /** Text size CSS variables */
- textSize?: StyleXStyles;
- /** Line height CSS variables */
- lineHeight?: StyleXStyles;
- /** Font weight CSS variables */
- fontWeight?: StyleXStyles;
-}
-
-/**
- * Raw token values for programmatic access.
- * Useful for charting libraries, theme editors, or parsing light-dark() values.
- * All fields are optional — partial themes only include overridden groups.
- *
- * @deprecated Use `defineTheme()` — token values are accessible via `theme.tokens`.
- */
-export interface ThemeRaw {
- colors?: Record<string, string>;
- spacing?: Record<string, string>;
- size?: Record<string, string>;
- radius?: Record<string, string>;
- elevation?: Record<string, string>;
- transition?: Record<string, string>;
- typography?: Record<string, string>;
- textSize?: Record<string, string>;
- lineHeight?: Record<string, string>;
- fontWeight?: Record<string, string>;
-}
-
-/**
- * Theme object - pre-compiled StyleX styles that set CSS variables.
- *
- * @deprecated Use `defineTheme()` from `@xds/core/theme` to create themes.
- * The `XDSDefinedTheme` type replaces this interface. All shipped themes
- * (default, neutral, brutalist) now use `defineTheme()`.
- */
-export interface Theme {
- /** Theme name */
- name: string;
- /** StyleX styles containing CSS variable definitions */
- styles: ThemeStyles;
- /** Component-specific style overrides (optional) */
- components?: ComponentStyles;
- /** Optional icon registry for overriding built-in fallback icons */
- icons?: Partial<XDSIconRegistry>;
- /** Raw token values for programmatic access (optional) */
- raw?: ThemeRaw;
-}
diff --git a/packages/themes/default/esbuild-plugin-babel.d.ts b/packages/themes/default/esbuild-plugin-babel.d.ts
deleted file mode 100644
index 770031ab2a..0000000000
--- a/packages/themes/default/esbuild-plugin-babel.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-declare module 'esbuild-plugin-babel';
diff --git a/packages/themes/default/tsconfig.json b/packages/themes/default/tsconfig.json
deleted file mode 100644
index 5f7cca32c5..0000000000
--- a/packages/themes/default/tsconfig.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "extends": "../../../tsconfig.json",
- "compilerOptions": {
- "outDir": "./dist",
- "paths": {
- "@xds/core/*": ["../../core/src/*"],
- "@xds/core": ["../../core/src"]
- }
- },
- "include": ["src"]
-}
diff --git a/packages/themes/neutral/esbuild-plugin-babel.d.ts b/packages/themes/neutral/esbuild-plugin-babel.d.ts
deleted file mode 100644
index 770031ab2a..0000000000
--- a/packages/themes/neutral/esbuild-plugin-babel.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-declare module 'esbuild-plugin-babel';
diff --git a/packages/themes/neutral/tsconfig.json b/packages/themes/neutral/tsconfig.json
deleted file mode 100644
index 5f7cca32c5..0000000000
--- a/packages/themes/neutral/tsconfig.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "extends": "../../../tsconfig.json",
- "compilerOptions": {
- "outDir": "./dist",
- "paths": {
- "@xds/core/*": ["../../core/src/*"],
- "@xds/core": ["../../core/src"]
- }
- },
- "include": ["src"]
-}