Skip to content

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

TypeScript

feat(core): reflect visual props as data attributes (#2792)

Cindy Zhang3814badd62a0
diff --git a/.changeset/data-attribute-selectors.md b/.changeset/data-attribute-selectors.md
new file mode 100644
index 0000000000..80eea46d46
--- /dev/null
+++ b/.changeset/data-attribute-selectors.md
@@ -0,0 +1,6 @@
+---
+'@xds/core': minor
+'@xds/cli': patch
+---
+
+Dual-emit data attributes for XDS visual prop/state selector reflection while preserving legacy bare variant classes, and document the data-attribute selector surface in CLI docs.
diff --git a/apps/docsite/src/components/ThemePackagePage.tsx b/apps/docsite/src/components/ThemePackagePage.tsx
index 9aeb835e65..ba84a93f06 100644
--- a/apps/docsite/src/components/ThemePackagePage.tsx
+++ b/apps/docsite/src/components/ThemePackagePage.tsx
@@ -331,7 +331,8 @@ const styles = stylex.create({
// (distressed display), and themes without a display family
// override fall back to their heading font (Outfit, system,
// etc.). The XDSText below uses type="display-3" so the
- // .xds-text.display-3 selector in each theme's @scope'd CSS
+ // .xds-text.display-3 selector in each theme's @scope'd CSS (legacy class
+ // selector; text also emits data-type="display-3")
// applies the right family per card.
fontSize: 32,
lineHeight: 1.2,
diff --git a/apps/docsite/src/components/ThemeShowcaseTile.tsx b/apps/docsite/src/components/ThemeShowcaseTile.tsx
index 016c32eb76..5df7a9d421 100644
--- a/apps/docsite/src/components/ThemeShowcaseTile.tsx
+++ b/apps/docsite/src/components/ThemeShowcaseTile.tsx
@@ -222,7 +222,8 @@ const styles = stylex.create({
// Each typography sample sizes itself uniformly via a wrapper
// class. The actual font family + weight comes from the underlying
// XDSText / span using the theme's own typography tokens (or, for
- // Display, the theme-scoped .xds-text.display-3 rule which themes
+ // Display, the theme-scoped .xds-text.display-3 rule (legacy class selector;
+ // text also emits data-type="display-3") which themes
// like Gothic use to swap in a signature display family).
typeAa: {
display: 'inline-block',
@@ -475,7 +476,7 @@ export function ThemeShowcaseTile({
display / heading / body / mono font with the role as
label. The Display sample uses XDSText type="display-3"
so themes that scope a custom display family to the
- .xds-text.display-3 selector (e.g. Gothic →
+ .xds-text.display-3 selector (legacy class selector; e.g. Gothic →
Manufacturing Consent) flow through cleanly. */}
<XDSHStack gap={3}>
<XDSVStack gap={0.5} xstyle={styles.typeSample}>
diff --git a/apps/docsite/src/components/themePlayground/constants.ts b/apps/docsite/src/components/themePlayground/constants.ts
index 2b9a3448aa..fc845b5ba1 100644
--- a/apps/docsite/src/components/themePlayground/constants.ts
+++ b/apps/docsite/src/components/themePlayground/constants.ts
@@ -267,7 +267,7 @@ export const COMPONENT_VARS: Record<
};
// Maps component CSS var names to defineTheme() components entries.
-// Most use the derivedVarRegistry keys (which match CSS class names).
+// Most use the derivedVarRegistry keys (which match XDS component selector keys).
// Some components set internal --_ vars via StyleX on a child element,
// so we target the child class directly with the internal var name.
export const COMPONENT_VAR_TO_OVERRIDE: Record<
diff --git a/apps/storybook/stories/Outline.stories.tsx b/apps/storybook/stories/Outline.stories.tsx
index 068a37a31c..aeaa0612f7 100644
--- a/apps/storybook/stories/Outline.stories.tsx
+++ b/apps/storybook/stories/Outline.stories.tsx
@@ -133,8 +133,8 @@ export const WithDocument: Story = {
</p>
<h3 id="component-overrides">Component overrides</h3>
<p>
- Component overrides target stable xds-* class names emitted by each
- component.
+ Component overrides target the stable XDS selector surface emitted
+ by each component: xds-* classes plus data-* prop reflections.
</p>
</section>
<section>
diff --git a/packages/cli/docs/styling.doc.mjs b/packages/cli/docs/styling.doc.mjs
index a1359d90cd..76d334a038 100644
--- a/packages/cli/docs/styling.doc.mjs
+++ b/packages/cli/docs/styling.doc.mjs
@@ -219,37 +219,67 @@ const overrides = stylex.create({
],
},
{
- title: 'Theming via xds-* Class Names',
+ title: 'Preferred Selector Surface: Data Attributes',
category: 'guide',
content: [
{
type: 'prose',
- text: 'Every component renders a stable xds-* class name (e.g. xds-button, xds-card) plus variant classes. These are the targeting surface for theme overrides in defineTheme. You rarely need to use them directly, but they\'re useful for debugging and for external CSS that needs to target components.',
+ text: 'When external CSS needs to target an XDS component by prop or state, combine the stable component class with reflected data attributes. The component class identifies the component (`.xds-button`, `.xds-card`); data attributes identify the axis and value (`data-variant`, `data-size`, `data-level`, etc.). This is the preferred selector surface for new CSS because it is explicit and collision-resistant.',
+ },
+ {
+ type: 'code',
+ lang: 'css',
+ code: `.my-app .xds-button[data-variant="primary"] {
+ /* primary buttons in this app context */
+}
+
+.my-app .xds-button[data-variant="primary"][data-size="sm"] {
+ /* small primary buttons */
+}
+
+.my-app .xds-heading[data-level="2"] {
+ /* level 2 headings; numeric values stay literal in data attrs */
+}`,
},
{
type: 'code',
lang: 'tsx',
- label: 'Class names rendered by components',
+ label: 'What components reflect',
code: `// <XDSButton variant="primary" size="sm" />
-// renders: class="xds-button primary sm ..."
+// preferred selector attrs: data-variant="primary" data-size="sm"
// <XDSCard variant="elevated" />
-// renders: class="xds-card elevated ..."
+// preferred selector attrs: data-variant="elevated"
// <XDSHeading level={2} />
-// renders: class="xds-heading level-2 ..."`,
+// preferred selector attrs: data-level="2"`,
},
{
- type: 'code',
- lang: 'css',
- label: 'Targeting in external CSS (escape hatch)',
- code: `.my-app .xds-button.primary {
- /* override primary button in this app context */
-}`,
+ type: 'prose',
+ text: 'For systematic theming, use defineTheme component overrides instead of raw CSS selectors. defineTheme keeps the higher-level `prop:value` API (`variant:primary`, `size:sm`) and handles selector generation for you. Run `npx xds docs theme` for the full theming guide.',
},
+ ],
+ },
+ {
+ title: 'Deprecated: Bare Prop and State Classes',
+ category: 'guide',
+ content: [
{
type: 'prose',
- text: 'For systematic theming, use defineTheme component overrides instead of raw CSS selectors. Run `npx xds docs theme` for the full theming guide.',
+ text: 'XDS still emits legacy bare prop/state classes such as `.primary`, `.sm`, `.level-2`, and `.checked` for compatibility with existing apps and built themes. Do not write new CSS against these bare classes. The stable base component classes (`.xds-button`, `.xds-card`, etc.) are not deprecated; only the unprefixed prop/state classes are the legacy surface.',
+ },
+ {
+ type: 'code',
+ lang: 'css',
+ code: `/* Deprecated compatibility selector — avoid in new CSS */
+.my-app .xds-button.primary {
+ /* use .xds-button[data-variant="primary"] instead */
+}
+
+/* Deprecated compatibility selector — avoid in new CSS */
+.my-app .xds-heading.level-2 {
+ /* use .xds-heading[data-level="2"] instead */
+}`,
},
],
},
diff --git a/packages/cli/docs/theme.doc.dense.mjs b/packages/cli/docs/theme.doc.dense.mjs
index 8a1d57b65a..e15470d205 100644
--- a/packages/cli/docs/theme.doc.dense.mjs
+++ b/packages/cli/docs/theme.doc.dense.mjs
@@ -10,7 +10,7 @@ export const docsDense = {
{ title: 'Props', content: [null] },
{ title: 'Custom Theme', content: [{ type: 'prose', text: 'CLI wizard or manual defineTheme. only override tokens that differ.' }, null] },
{ title: 'defineTheme', content: [{ type: 'prose', text: 'scale configs (color, typography, radius, motion) + explicit token overrides + component overrides. color derives full palette from accent hex via HCT.' }, null, null] },
- { title: 'Component Overrides', content: [{ type: 'prose', text: 'components field targets .xds-* classes. write standard CSS (borderRadius, padding) — pipeline expands to internal vars. public vars (--button-press-scale etc) set directly. private vars (--_*) cannot be set — use CSS properties. run `npx xds component <Name>` for details.' }, null, null, null, null] },
+ { title: 'Component Overrides', content: [{ type: 'prose', text: 'components field uses semantic component keys + style keys (base, variant:value, stateName), not raw selectors. for external CSS, prefer data-* selectors from `xds docs styling`. write standard CSS (borderRadius, padding) — pipeline expands to internal vars. public vars (--button-press-scale etc) set directly. private vars (--_*) cannot be set — use CSS properties. run `npx xds component <Name>` for details.' }, null, null, null, null] },
{ title: 'Custom Variants', content: [{ type: 'prose', text: 'any unknown prop:value in components becomes a new variant. xds theme build generates TS augmentations. works on any extensible prop axis (variant, status, etc).' }, null, null, null, null] },
{ title: 'Build for Production', content: [{ type: 'prose', text: 'npx xds theme build compiles defineTheme to static CSS. outputs .css + .js (__built:true) + .d.ts.' }, null, null, null, null] },
{ title: 'Runtime vs Built', content: [{ type: 'prose', text: 'runtime: useInsertionEffect injects styles client-side. built: static CSS on first paint. USE /built + theme.css FOR SSR.' }, null, null, null] },
diff --git a/packages/cli/docs/theme.doc.mjs b/packages/cli/docs/theme.doc.mjs
index 90484422e6..6687fe6888 100644
--- a/packages/cli/docs/theme.doc.mjs
+++ b/packages/cli/docs/theme.doc.mjs
@@ -227,7 +227,7 @@ const brandTheme = defineTheme({
content: [
{
type: 'prose',
- text: 'The `components` field in defineTheme targets stable `.xds-*` CSS class names. Use `base` for all instances, `variant:value` or `stateName` for specific states.',
+ text: 'The `components` field in defineTheme uses semantic component keys and style keys — not raw CSS selectors. Use `base` for all instances, `variant:value` or `stateName` for specific props/states, and let the theme pipeline choose the underlying selector. For raw external CSS escape hatches, prefer the data-attribute selector surface documented in `xds docs styling`.',
},
{
type: 'code',
diff --git a/packages/cli/src/commands/build-theme.mjs b/packages/cli/src/commands/build-theme.mjs
index 04234721c5..b1876828d3 100644
--- a/packages/cli/src/commands/build-theme.mjs
+++ b/packages/cli/src/commands/build-theme.mjs
@@ -249,14 +249,19 @@ function resolveTokenValue(value) {
}
/**
- * Parse a component style key into a CSS selector suffix.
+ * Parse a component style key into the legacy class selector suffix used by
+ * built theme CSS today.
* - `base` → ''
* - `variant:secondary` → '.secondary'
* - `level:1` → '.level-1' (digits get prefixed)
* - `variant:destructive+size:sm` → '.destructive.sm'
*
+ * Runtime components also emit matching data-* prop reflections via xdsThemeProps()
+ * (`data-variant="secondary"`, `data-level="1"`, etc.) for the data-attribute
+ * selector migration. Keep the class output here until the generator migrates.
+ *
* <!-- SYNC: packages/core/src/utils/parseStyleKey.ts -->
- * <!-- SYNC: packages/core/src/utils/xdsClassName.ts -->
+ * <!-- SYNC: packages/core/src/utils/xdsThemeProps.ts -->
* The digit-prefix and value-to-class logic must match across all three files.
*/
diff --git a/packages/cli/src/lib/component-format.mjs b/packages/cli/src/lib/component-format.mjs
index 0f4c25fe2f..a12ee4e593 100644
--- a/packages/cli/src/lib/component-format.mjs
+++ b/packages/cli/src/lib/component-format.mjs
@@ -12,6 +12,17 @@ function targetKey(target) {
return target.className.replace(/^xds-/, '');
}
+function dataAttrForName(name) {
+ return `data-${name.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase()}`;
+}
+
+function getTargetDataAttributes(target) {
+ return [
+ ...(target.visualProps || []).map(dataAttrForName),
+ ...(target.states || []).map(dataAttrForName),
+ ];
+}
+
function formatPropsTable(props) {
if (!props || props.length === 0) return '';
const lines = [];
@@ -69,8 +80,8 @@ function formatTargetsTable(docs, themeData) {
if (!docs.theming?.targets?.length) return '';
const lines = [];
- lines.push('| Class | Variants | States |');
- lines.push('|-------|----------|--------|');
+ lines.push('| Component class | Preferred data attributes | Props | States |');
+ lines.push('|-----------------|---------------------------|-------|--------|');
for (const target of docs.theming.targets) {
const coreVariants = getTargetVariants(target, docs);
@@ -89,8 +100,13 @@ function formatTargetsTable(docs, themeData) {
const variantsStr = variantParts.length > 0 ? variantParts.join(', ') : '—';
const statesStr = states.length > 0 ? states.join(', ') : '—';
+ const dataAttrs = getTargetDataAttributes(target);
+ const dataAttrsStr =
+ dataAttrs.length > 0 ? dataAttrs.map(attr => `\`${attr}\``).join(', ') : '—';
- lines.push(`| \`${target.className}\` | ${variantsStr} | ${statesStr} |`);
+ lines.push(
+ `| \`${target.className}\` | ${dataAttrsStr} | ${variantsStr} | ${statesStr} |`,
+ );
}
return lines.join('\n');
@@ -183,7 +199,7 @@ export function formatFull(docs, options = {}) {
}
}
- // Generate defineTheme example with class targeting
+ // Generate defineTheme example with component selector targeting
const exampleLines = ['Override in defineTheme:\n```ts\ncomponents: {'];
const rootTarget = docs.theming.targets[0];
const rootKey = targetKey(rootTarget);
@@ -420,11 +436,13 @@ export function formatBrief(docs, componentName, importHint, options = {}) {
output.push(` Derived: ${derivedNames}`);
}
-// Theme targets (class names, variants, states) with theme variant merging
+// Theme targets (component class, preferred data attrs, props, states) with theme variant merging
if (docs.theming?.targets?.length) {
const { themeData = null } = options;
const targetParts = docs.theming.targets.map(t => {
const parts = [t.className];
+ const dataAttrs = getTargetDataAttributes(t);
+ if (dataAttrs.length) parts.push(`preferred attrs: ${dataAttrs.join(', ')}`);
if (t.visualProps?.length) parts.push(`variants: ${t.visualProps.join(', ')}`);
if (t.states?.length) parts.push(`states: ${t.states.join(', ')}`);
// Merge theme variants
diff --git a/packages/core/docs.mjs b/packages/core/docs.mjs
index d4c6f948b6..6511949777 100644
--- a/packages/core/docs.mjs
+++ b/packages/core/docs.mjs
@@ -135,6 +135,17 @@ function extractExamples(docPath) {
// ── Formatting ───────────────────────────────────────────────────────
+function dataAttrForName(name) {
+ return `data-${name.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase()}`;
+}
+
+function getTargetDataAttributes(target) {
+ return [
+ ...(target.visualProps || []).map(dataAttrForName),
+ ...(target.states || []).map(dataAttrForName),
+ ];
+}
+
function formatPropsTable(props) {
if (!props?.length) return '';
const lines = ['| Prop | Type | Default | Description |', '|------|------|---------|-------------|'];
@@ -194,12 +205,14 @@ function formatFull(docs, docPath) {
if (docs.theming?.targets?.length) {
s.push('## Theming\n');
- s.push('| Class | Variants | States |');
- s.push('|-------|----------|--------|');
+ s.push('| Component class | Preferred data attributes | Props | States |');
+ s.push('|-----------------|---------------------------|-------|--------|');
for (const t of docs.theming.targets) {
+ const dataAttrs = getTargetDataAttributes(t);
+ const attrs = dataAttrs.length ? dataAttrs.map(attr => `\`${attr}\``).join(', ') : '—';
const variants = t.visualProps?.join(', ') || '—';
const states = t.states?.join(', ') || '—';
- s.push(`| \`${t.className}\` | ${variants} | ${states} |`);
+ s.push(`| \`${t.className}\` | ${attrs} | ${variants} | ${states} |`);
}
s.push('');
const publicVars = docs.theming.vars?.filter(v => !v.private && !v.derived) || [];
diff --git a/packages/core/src/AlertDialog/XDSAlertDialog.tsx b/packages/core/src/AlertDialog/XDSAlertDialog.tsx
index c8c2e05c19..e1b74fe2fd 100644
--- a/packages/core/src/AlertDialog/XDSAlertDialog.tsx
+++ b/packages/core/src/AlertDialog/XDSAlertDialog.tsx
@@ -26,7 +26,8 @@ import {XDSHeading} from '../Heading/XDSHeading';
import {XDSText} from '../Text/XDSText';
import {XDSButton, type XDSButtonVariant} from '../Button';
import type {XDSBaseProps} from '../XDSBaseProps';
-import {xdsClassName} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
export interface XDSAlertDialogProps extends XDSBaseProps<HTMLDialogElement> {
ref?: React.Ref<HTMLDialogElement>;
@@ -150,11 +151,8 @@ export function XDSAlertDialog({
role="alertdialog"
aria-labelledby={titleId}
aria-describedby={descriptionId}
- className={
- xdsClassName('alert-dialog') + (className ? ` ${className}` : '')
- }
+ {...mergeProps(xdsThemeProps('alert-dialog'), {className, style})}
xstyle={xstyle}
- style={style}
data-testid={testId}>
<XDSLayout
content={
diff --git a/packages/core/src/AppShell/XDSAppShell.tsx b/packages/core/src/AppShell/XDSAppShell.tsx
index 216b05a08a..92734e61a8 100644
--- a/packages/core/src/AppShell/XDSAppShell.tsx
+++ b/packages/core/src/AppShell/XDSAppShell.tsx
@@ -49,9 +49,10 @@ import {XDSAppShellMobileContext} from './XDSAppShellMobileContext';
import type {XDSAppShellMobileContextValue} from './XDSAppShellMobileContext';
import type {SpacingStep} from '../utils/types';
import type {XDSBaseProps} from '../XDSBaseProps';
-import {xdsClassName, mergeProps, mergeRefs, isRenderable} from '../utils';
+import {mergeProps, mergeRefs, isRenderable} from '../utils';
import {useMediaQuery} from '../hooks/useMediaQuery';
import {observeResize, unobserveResize} from '../utils/sharedResizeObserver';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const HasActivity = typeof React.Activity !== 'undefined';
const ActivityWrapper = HasActivity
@@ -669,7 +670,7 @@ export function XDSAppShell({
<div
ref={headerRef}
{...mergeProps(
- xdsClassName('app-shell-header', {variant}),
+ xdsThemeProps('app-shell-header', {variant}),
stylex.props(navAreaStyle, isAuto && styles.headerSticky),
)}>
{headerInner}
@@ -689,7 +690,7 @@ export function XDSAppShell({
padding={0}
hasDivider={navHasDividers}
isScrollable={isFill}
- className={xdsClassName('app-shell-sidenav', {variant})}
+ {...xdsThemeProps('app-shell-sidenav', {variant})}
xstyle={[
navAreaStyle,
isAuto && stickyBgStyle,
@@ -750,7 +751,7 @@ export function XDSAppShell({
shouldShowAutoToggle && !hasTopNav && hasSideNav ? (
<div
{...mergeProps(
- xdsClassName('app-shell-header', {variant}),
+ xdsThemeProps('app-shell-header', {variant}),
stylex.props(navAreaStyle, isAuto && styles.headerSticky),
)}>
<XDSLayoutHeader padding={0} hasDivider={navHasDividers}>
@@ -773,7 +774,7 @@ export function XDSAppShell({
ref={mergeRefs(ref, shellRef)}
data-testid={dataTestId}
{...mergeProps(
- xdsClassName('app-shell', {variant}),
+ xdsThemeProps('app-shell', {variant}),
stylex.props(
styles.root,
variant === 'wash'
diff --git a/packages/core/src/AspectRatio/XDSAspectRatio.tsx b/packages/core/src/AspectRatio/XDSAspectRatio.tsx
index 3d88ab0031..8720a604f6 100644
--- a/packages/core/src/AspectRatio/XDSAspectRatio.tsx
+++ b/packages/core/src/AspectRatio/XDSAspectRatio.tsx
@@ -18,7 +18,8 @@
import type {ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import type {XDSBaseProps} from '../XDSBaseProps';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
/**
* The shape of the aspect ratio container.
@@ -122,7 +123,7 @@ export function XDSAspectRatio({
<div
ref={ref}
{...mergeProps(
- xdsClassName('aspect-ratio', {shape}),
+ xdsThemeProps('aspect-ratio', {shape}),
stylex.props(
styles.container,
shape === 'ellipse' && styles.ellipse,
diff --git a/packages/core/src/Avatar/XDSAvatar.tsx b/packages/core/src/Avatar/XDSAvatar.tsx
index 3f46df59c8..e3e229bcda 100644
--- a/packages/core/src/Avatar/XDSAvatar.tsx
+++ b/packages/core/src/Avatar/XDSAvatar.tsx
@@ -26,7 +26,8 @@ import {
} from '../theme/tokens.stylex';
import {XDSAvatarSizeContext} from './XDSAvatarSizeContext';
import {useXDSAvatarGroup} from '../AvatarGroup/XDSAvatarGroupContext';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
/**
* The offset ratio for positioning elements on a circle's edge at 45°.
@@ -309,7 +310,7 @@ export function XDSAvatar({
aria-label={accessibleName}
data-testid={testId}
{...mergeProps(
- xdsClassName('avatar', {size: resolvedSize}),
+ xdsThemeProps('avatar', {size: resolvedSize}),
stylex.props(
styles.wrapper,
avatarGroup && groupStyles.ring,
diff --git a/packages/core/src/Avatar/XDSAvatarStatusDot.tsx b/packages/core/src/Avatar/XDSAvatarStatusDot.tsx
index b65d8a9a84..4ec109c85f 100644
--- a/packages/core/src/Avatar/XDSAvatarStatusDot.tsx
+++ b/packages/core/src/Avatar/XDSAvatarStatusDot.tsx
@@ -20,7 +20,8 @@ import type {XDSBaseProps} from '../XDSBaseProps';
import * as stylex from '@stylexjs/stylex';
import {colorVars, radiusVars} from '../theme/tokens.stylex';
import {XDSAvatarSizeContext} from './XDSAvatarSizeContext';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
/**
* Resolves the status dot size, border width, and icon size based on the
@@ -195,7 +196,7 @@ export function XDSAvatarStatusDot({
ref={ref}
{...(label ? {role: 'img', 'aria-label': label} : undefined)}
{...mergeProps(
- xdsClassName('avatar-status-dot', {variant}),
+ xdsThemeProps('avatar-status-dot', {variant}),
stylex.props(
styles.dot,
variantStyleMap[variant],
diff --git a/packages/core/src/AvatarGroup/XDSAvatarGroup.tsx b/packages/core/src/AvatarGroup/XDSAvatarGroup.tsx
index 7b023545d6..3316e1e31d 100644
--- a/packages/core/src/AvatarGroup/XDSAvatarGroup.tsx
+++ b/packages/core/src/AvatarGroup/XDSAvatarGroup.tsx
@@ -22,8 +22,9 @@ import {useMemo, type ReactNode} from 'react';
import type {XDSBaseProps} from '../XDSBaseProps';
import {resolveSize, type XDSAvatarSize} from '../Avatar';
import * as stylex from '@stylexjs/stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {XDSAvatarGroupContext} from './XDSAvatarGroupContext';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const OVERLAP_RATIO = 0.25;
@@ -98,7 +99,7 @@ export function XDSAvatarGroup({
aria-label={ariaLabel}
data-testid={testId}
{...mergeProps(
- xdsClassName('avatar-group', {size}),
+ xdsThemeProps('avatar-group', {size}),
stylex.props(styles.root, xstyle),
className,
style,
diff --git a/packages/core/src/AvatarGroup/XDSAvatarGroupOverflow.tsx b/packages/core/src/AvatarGroup/XDSAvatarGroupOverflow.tsx
index 57a5f38ff6..3a343fb37b 100644
--- a/packages/core/src/AvatarGroup/XDSAvatarGroupOverflow.tsx
+++ b/packages/core/src/AvatarGroup/XDSAvatarGroupOverflow.tsx
@@ -21,9 +21,10 @@ import {
fontWeightVars,
radiusVars,
} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {useXDSAvatarGroup} from './XDSAvatarGroupContext';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const BORDER_WIDTH = 2;
const OVERFLOW_FONT_RATIO = 0.35;
@@ -147,7 +148,7 @@ export function XDSAvatarGroupOverflow({
onClick={onClick}
aria-label={label}
{...mergeProps(
- xdsClassName('avatar-group-overflow'),
+ xdsThemeProps('avatar-group-overflow'),
stylex.props(
styles.base,
styles.button,
@@ -170,7 +171,7 @@ export function XDSAvatarGroupOverflow({
ref={ref}
aria-label={label}
{...mergeProps(
- xdsClassName('avatar-group-overflow'),
+ xdsThemeProps('avatar-group-overflow'),
stylex.props(
styles.base,
styles.overlap,
diff --git a/packages/core/src/Badge/XDSBadge.tsx b/packages/core/src/Badge/XDSBadge.tsx
index 06de40cb41..4bc510d594 100644
--- a/packages/core/src/Badge/XDSBadge.tsx
+++ b/packages/core/src/Badge/XDSBadge.tsx
@@ -26,7 +26,8 @@ import {
fontWeightVars,
typeScaleVars,
} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
/**
* Base badge styles
@@ -197,7 +198,7 @@ export function XDSBadge({
<span
ref={ref}
{...mergeProps(
- xdsClassName('badge', {variant}),
+ xdsThemeProps('badge', {variant}),
stylex.props(styles.base, variants[variant], xstyle),
className,
style,
diff --git a/packages/core/src/Banner/XDSBanner.tsx b/packages/core/src/Banner/XDSBanner.tsx
index 8dfeaa5fa6..e398c0dd88 100644
--- a/packages/core/src/Banner/XDSBanner.tsx
+++ b/packages/core/src/Banner/XDSBanner.tsx
@@ -10,8 +10,8 @@
*
* Visual structure:
* - Root container: layout-only wrapper (flex column), no visual styling, no theme target
- * - Header area (xdsClassName 'banner'): colored status background with icon, title, description, actions, dismiss
- * - Content area (xdsClassName 'banner-content'): collapsible card background for additional content (children)
+ * - Header area (xdsThemeProps 'banner'): colored status background with icon, title, description, actions, dismiss
+ * - Content area (xdsThemeProps 'banner-content'): collapsible card background for additional content (children)
* - No left border accent — color is expressed through the full header background
* - Each visual area owns its own border-radius (no overflow:clip on the container)
* - When children are provided, a collapse/expand toggle button appears in the end area
@@ -40,8 +40,9 @@ import {
durationVars,
easeVars,
} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {edgeCompSlot} from '../Layout/edgeCompensation.stylex';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Types
@@ -416,7 +417,7 @@ export function XDSBanner({
{/* Header: colored status background — primary theme target ('banner') */}
<div
{...mergeProps(
- xdsClassName('banner', {container, status}),
+ xdsThemeProps('banner', {container, status}),
stylex.props(
styles.header,
isSingleLine && styles.headerCentered,
@@ -429,7 +430,7 @@ export function XDSBanner({
)}>
<div
{...mergeProps(
- xdsClassName('banner-icon', {status}),
+ xdsThemeProps('banner-icon', {status}),
stylex.props(styles.iconWrapper),
)}
aria-hidden="true">
@@ -490,7 +491,7 @@ export function XDSBanner({
{showContent && (
<div
{...mergeProps(
- xdsClassName('banner-content', {container, status}),
+ xdsThemeProps('banner-content', {container, status}),
stylex.props(styles.contentArea, isCard && styles.contentAreaCard),
)}>
{children}
diff --git a/packages/core/src/Blockquote/XDSBlockquote.tsx b/packages/core/src/Blockquote/XDSBlockquote.tsx
index e56d6c7af7..22dc18e9ff 100644
--- a/packages/core/src/Blockquote/XDSBlockquote.tsx
+++ b/packages/core/src/Blockquote/XDSBlockquote.tsx
@@ -19,7 +19,8 @@ import type {ReactNode} from 'react';
import type {XDSBaseProps} from '../XDSBaseProps';
import * as stylex from '@stylexjs/stylex';
import {colorVars, spacingVars, typeScaleVars} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
export interface XDSBlockquoteProps extends XDSBaseProps<HTMLQuoteElement> {
/** Ref forwarded to the root <blockquote> element */
@@ -77,7 +78,7 @@ export function XDSBlockquote({
<blockquote
ref={ref}
{...mergeProps(
- xdsClassName('blockquote'),
+ xdsThemeProps('blockquote'),
stylex.props(styles.root, xstyle),
className,
style,
diff --git a/packages/core/src/Breadcrumbs/XDSBreadcrumbItem.tsx b/packages/core/src/Breadcrumbs/XDSBreadcrumbItem.tsx
index 5c8ed81080..37b300a32b 100644
--- a/packages/core/src/Breadcrumbs/XDSBreadcrumbItem.tsx
+++ b/packages/core/src/Breadcrumbs/XDSBreadcrumbItem.tsx
@@ -28,8 +28,9 @@ import {colorVars, spacingVars, typeScaleVars} from '../theme/tokens.stylex';
import {BreadcrumbContext} from './XDSBreadcrumbs';
import {useXDSLinkComponent} from '../Link/useXDSLinkComponent';
import type {XDSLinkComponentType} from '../Link/types';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Props
@@ -230,7 +231,7 @@ export function XDSBreadcrumbItem({
<li
ref={mergeRefs(ref, liRef)}
{...mergeProps(
- xdsClassName('breadcrumb-item'),
+ xdsThemeProps('breadcrumb-item'),
stylex.props(
itemStyles.root,
isSupporting ? itemStyles.supportingSize : itemStyles.defaultSize,
@@ -264,7 +265,7 @@ export function XDSBreadcrumbItem({
<li
ref={mergeRefs(ref, liRef)}
{...mergeProps(
- xdsClassName('breadcrumb-item'),
+ xdsThemeProps('breadcrumb-item'),
stylex.props(
itemStyles.root,
isSupporting ? itemStyles.supportingSize : itemStyles.defaultSize,
diff --git a/packages/core/src/Breadcrumbs/XDSBreadcrumbs.tsx b/packages/core/src/Breadcrumbs/XDSBreadcrumbs.tsx
index 9527e63f21..2d3c0b8af9 100644
--- a/packages/core/src/Breadcrumbs/XDSBreadcrumbs.tsx
+++ b/packages/core/src/Breadcrumbs/XDSBreadcrumbs.tsx
@@ -19,8 +19,9 @@
import {createContext, useMemo, type ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import {spacingVars} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Variant type
@@ -164,7 +165,7 @@ export function XDSBreadcrumbs({
ref={ref}
aria-label={label}
{...mergeProps(
- xdsClassName('breadcrumbs', {variant}),
+ xdsThemeProps('breadcrumbs', {variant}),
stylex.props(navStyles.root, xstyle),
className,
style,
diff --git a/packages/core/src/Button/XDSButton.test.tsx b/packages/core/src/Button/XDSButton.test.tsx
index 35b7bf2b04..c0960bdc43 100644
--- a/packages/core/src/Button/XDSButton.test.tsx
+++ b/packages/core/src/Button/XDSButton.test.tsx
@@ -187,12 +187,14 @@ describe('XDSButton', () => {
expect(button).toHaveAttribute('aria-busy', 'true');
});
- it('renders xds-* class names for theme targeting', () => {
+ it('renders xds-* classes and data attributes for theme targeting', () => {
render(<XDSButton label="Test" variant="secondary" size="sm" />);
const button = screen.getByRole('button');
expect(button.className).toContain('xds-button');
expect(button.className).toContain('secondary');
expect(button.className).toContain('sm');
+ expect(button).toHaveAttribute('data-variant', 'secondary');
+ expect(button).toHaveAttribute('data-size', 'sm');
});
// P0: onClick fires before clickAction, clickAction respects preventDefault
diff --git a/packages/core/src/Button/XDSButton.tsx b/packages/core/src/Button/XDSButton.tsx
index d6f8c0bb7d..1db8bbfec5 100644
--- a/packages/core/src/Button/XDSButton.tsx
+++ b/packages/core/src/Button/XDSButton.tsx
@@ -38,9 +38,10 @@ import {XDSSpinner} from '../Spinner';
import {EDGE_COMP_ATTR} from '../Layout/edgeCompensation.stylex';
import {useXDSSize} from '../SizeContext/XDSSizeContext';
import {useXDSButtonGroup} from '../ButtonGroup/XDSButtonGroupContext';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {useXDSLinkComponent} from '../Link/useXDSLinkComponent';
import type {XDSLinkComponentType} from '../Link/types';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
/**
* Base button styles
@@ -588,7 +589,7 @@ export function XDSButton({
);
const sharedMergedProps = mergeProps(
- xdsClassName('button', {variant, size}),
+ xdsThemeProps('button', {variant, size}),
sharedStylexProps,
className,
style,
diff --git a/packages/core/src/ButtonGroup/XDSButtonGroup.tsx b/packages/core/src/ButtonGroup/XDSButtonGroup.tsx
index 1b60052514..df71f2ce77 100644
--- a/packages/core/src/ButtonGroup/XDSButtonGroup.tsx
+++ b/packages/core/src/ButtonGroup/XDSButtonGroup.tsx
@@ -25,10 +25,11 @@ import * as stylex from '@stylexjs/stylex';
import type {XDSButtonSize} from '../Button';
import {XDSSizeProvider, useXDSSize} from '../SizeContext/XDSSizeContext';
import {useListFocus} from '../hooks/useListFocus';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
import {XDSButtonGroupContext} from './XDSButtonGroupContext';
import type {XDSButtonGroupOrientation} from './XDSButtonGroupContext';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Props
@@ -144,7 +145,7 @@ export function XDSButtonGroup({
aria-disabled={isDisabled || undefined}
data-testid={testId}
{...mergeProps(
- xdsClassName('button-group', {size, orientation}),
+ xdsThemeProps('button-group', {size, orientation}),
stylex.props(
styles.group,
orientation === 'vertical' && styles.vertical,
diff --git a/packages/core/src/Calendar/XDSCalendar.tsx b/packages/core/src/Calendar/XDSCalendar.tsx
index 5c36e3fd29..a5b2572d9d 100644
--- a/packages/core/src/Calendar/XDSCalendar.tsx
+++ b/packages/core/src/Calendar/XDSCalendar.tsx
@@ -58,7 +58,7 @@ import {
DATE_FORMAT_WITH_WEEKDAY,
DATE_FORMAT_MONTH_YEAR,
} from '../utils/plainDate';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {
computeDayCellState,
computeRangeRounding,
@@ -72,6 +72,7 @@ import {
export type {ISODateString, DayOfWeek, DateRange} from '../utils/dateTypes';
import type {ISODateString, DayOfWeek, DateRange} from '../utils/dateTypes';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
/** Imperative handle for XDSCalendar handleRef */
@@ -397,7 +398,7 @@ export function XDSCalendar({ref, ...props}: XDSCalendarProps) {
<div
ref={ref}
{...mergeProps(
- xdsClassName('calendar', {mode}),
+ xdsThemeProps('calendar', {mode}),
stylex.props(calendarStyles.calendar, xstyle),
className,
style,
@@ -873,7 +874,7 @@ function DayCell({
onMouseEnter={() => !state.effectivelyDisabled && onDayHover(date)}
onMouseLeave={() => onDayHover(null)}
{...mergeProps(
- xdsClassName('calendar-day', {
+ xdsThemeProps('calendar-day', {
selected: endpoint ? 'selected' : null,
today: state.isToday ? 'today' : null,
disabled: state.effectivelyDisabled ? 'disabled' : null,
diff --git a/packages/core/src/Card/XDSCard.tsx b/packages/core/src/Card/XDSCard.tsx
index fe07eb458e..52a5a935d8 100644
--- a/packages/core/src/Card/XDSCard.tsx
+++ b/packages/core/src/Card/XDSCard.tsx
@@ -28,8 +28,9 @@ import {
spacingStepToToken,
} from '../Layout/padding.stylex';
import type {SizeValue, SpacingStep} from '../utils/types';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Variant type
@@ -261,7 +262,7 @@ export function XDSCard({
<div
ref={ref}
{...mergeProps(
- xdsClassName('card', {variant}),
+ xdsThemeProps('card', {variant}),
stylex.props(
styles.card,
variantStyles[variant],
diff --git a/packages/core/src/Carousel/XDSCarousel.tsx b/packages/core/src/Carousel/XDSCarousel.tsx
index 163553a4cd..e30d8e9991 100644
--- a/packages/core/src/Carousel/XDSCarousel.tsx
+++ b/packages/core/src/Carousel/XDSCarousel.tsx
@@ -31,8 +31,9 @@ import {XDSIcon} from '../Icon';
import {useXDSLayer} from '../Layer';
import {useScrollOverflow} from '../hooks/useScrollOverflow';
import type {XDSBaseProps} from '../XDSBaseProps';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import type {SpacingStep} from '../utils/types';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
export interface XDSCarouselProps extends XDSBaseProps<HTMLDivElement> {
ref?: React.Ref<HTMLDivElement>;
@@ -324,7 +325,7 @@ export function XDSCarousel({
aria-label={ariaLabel}
aria-roledescription="carousel"
{...mergeProps(
- xdsClassName('carousel'),
+ xdsThemeProps('carousel'),
stylex.props(styles.root, xstyle),
className,
style,
diff --git a/packages/core/src/Center/XDSCenter.tsx b/packages/core/src/Center/XDSCenter.tsx
index f0dd792f32..a7033e55b8 100644
--- a/packages/core/src/Center/XDSCenter.tsx
+++ b/packages/core/src/Center/XDSCenter.tsx
@@ -19,7 +19,8 @@ import type {ReactNode} from 'react';
import type {XDSBaseProps} from '../XDSBaseProps';
import * as stylex from '@stylexjs/stylex';
import type {SizeValue} from '../utils/types';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const styles = stylex.create({
base: {
@@ -111,7 +112,7 @@ export function XDSCenter({
...props
}: XDSCenterProps) {
const stylexProps = mergeProps(
- xdsClassName('center', {axis}),
+ xdsThemeProps('center', {axis}),
stylex.props(
isInline ? styles.inline : styles.base,
(axis === 'both' || axis === 'vertical') && styles.alignItemsCenter,
diff --git a/packages/core/src/Chat/XDSChatComposer.tsx b/packages/core/src/Chat/XDSChatComposer.tsx
index 886a1d46a9..e95a39a8ee 100644
--- a/packages/core/src/Chat/XDSChatComposer.tsx
+++ b/packages/core/src/Chat/XDSChatComposer.tsx
@@ -43,11 +43,12 @@ import {
typeScaleVars,
typographyVars,
} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {XDSIcon} from '../Icon';
import {XDSChatComposerInput} from './XDSChatComposerInput';
import {XDSChatComposerContext} from './XDSChatContext';
import {XDSChatSendButton} from './XDSChatSendButton';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Types
@@ -383,7 +384,7 @@ export function XDSChatComposer(props: XDSChatComposerProps) {
<div
ref={ref}
{...mergeProps(
- xdsClassName('chat-composer', {density}),
+ xdsThemeProps('chat-composer', {density}),
stylex.props(styles.root, isDisabled && styles.rootDisabled),
className,
style,
diff --git a/packages/core/src/Chat/XDSChatComposerDrawer.tsx b/packages/core/src/Chat/XDSChatComposerDrawer.tsx
index d5b74da813..6313ab7e46 100644
--- a/packages/core/src/Chat/XDSChatComposerDrawer.tsx
+++ b/packages/core/src/Chat/XDSChatComposerDrawer.tsx
@@ -27,8 +27,9 @@ import {
typeScaleVars,
} from '../theme/tokens.stylex';
import {XDSBadge} from '../Badge';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
export interface XDSChatComposerDrawerProps extends XDSBaseProps<HTMLDivElement> {
ref?: React.Ref<HTMLDivElement>;
@@ -249,7 +250,7 @@ export function XDSChatComposerDrawer({
ref={ref}
data-testid={testId}
{...mergeProps(
- xdsClassName('chat-composer-drawer', {
+ xdsThemeProps('chat-composer-drawer', {
collapsed: isCollapsed ? 'collapsed' : null,
}),
stylex.props(styles.root, xstyle),
diff --git a/packages/core/src/Chat/XDSChatComposerInput.tsx b/packages/core/src/Chat/XDSChatComposerInput.tsx
index 528963958d..868c307593 100644
--- a/packages/core/src/Chat/XDSChatComposerInput.tsx
+++ b/packages/core/src/Chat/XDSChatComposerInput.tsx
@@ -41,7 +41,7 @@ import {
typeScaleVars,
typographyVars,
} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {useTriggerMenu} from './useTriggerMenu';
import {
useXDSChatComposerTokens,
@@ -55,6 +55,7 @@ import {
} from './useXDSChatPasteAsToken';
import {XDSBadge, type XDSBadgeProps} from '../Badge';
import {useXDSChatComposerContext} from './XDSChatContext';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Types
@@ -618,7 +619,7 @@ export function XDSChatComposerInput(props: XDSChatComposerInputProps) {
<div
ref={ref}
{...mergeProps(
- xdsClassName('chat-composer-input'),
+ xdsThemeProps('chat-composer-input'),
stylex.props(styles.root, isDisabled && styles.disabled, xstyle),
className,
style,
diff --git a/packages/core/src/Chat/XDSChatLayout.tsx b/packages/core/src/Chat/XDSChatLayout.tsx
index 545051200d..a3f7e0faaa 100644
--- a/packages/core/src/Chat/XDSChatLayout.tsx
+++ b/packages/core/src/Chat/XDSChatLayout.tsx
@@ -26,11 +26,12 @@ import {type ReactNode, useMemo, useRef} from 'react';
import * as stylex from '@stylexjs/stylex';
import {spacingVars} from '../theme/tokens.stylex';
import type {XDSBaseProps} from '../XDSBaseProps';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import {useXDSChatStreamScroll} from './useXDSChatStreamScroll';
import {useXDSChatNewMessages} from './useXDSChatNewMessages';
import {XDSChatLayoutScrollButton} from './XDSChatLayoutScrollButton';
import {XDSChatLayoutContext} from './XDSChatContext';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Types
@@ -329,7 +330,7 @@ export function XDSChatLayout({
ref={mergeRefs(ref, rootRef)}
data-testid={testId}
{...mergeProps(
- xdsClassName('chat-layout', {density}),
+ xdsThemeProps('chat-layout', {density}),
stylex.props(
styles.root,
isSelfScrolling && styles.rootScrollable,
diff --git a/packages/core/src/Chat/XDSChatMessage.tsx b/packages/core/src/Chat/XDSChatMessage.tsx
index 4988f849ce..b7f8ead19e 100644
--- a/packages/core/src/Chat/XDSChatMessage.tsx
+++ b/packages/core/src/Chat/XDSChatMessage.tsx
@@ -33,8 +33,9 @@ import {
type XDSChatMessageSender,
type XDSChatDensity,
} from './XDSChatContext';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
export interface XDSChatMessageProps extends XDSBaseProps<HTMLElement> {
ref?: React.Ref<HTMLElement>;
@@ -220,7 +221,7 @@ export function XDSChatMessage({
aria-label={!hasName ? `Message from ${sender}` : undefined}
aria-labelledby={hasName ? nameId : undefined}
{...mergeProps(
- xdsClassName('chat-message', {sender, density}),
+ xdsThemeProps('chat-message', {sender, density}),
stylex.props(
styles.root,
rootAlignment,
diff --git a/packages/core/src/Chat/XDSChatMessageBubble.tsx b/packages/core/src/Chat/XDSChatMessageBubble.tsx
index 9983544426..307361f25e 100644
--- a/packages/core/src/Chat/XDSChatMessageBubble.tsx
+++ b/packages/core/src/Chat/XDSChatMessageBubble.tsx
@@ -35,8 +35,9 @@ import {
typographyVars,
} from '../theme/tokens.stylex';
import {useXDSChatMessageContext} from './XDSChatContext';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
export type XDSChatMessageBubbleVariant = 'filled' | 'ghost';
@@ -145,7 +146,8 @@ const styles = stylex.create({
textAlign: 'end',
},
// Sender backgrounds — same default, but separate styles for theme overrides.
- // Themes can target .xds-chat-message-bubble.user vs .assistant via @scope.
+ // Themes can target sender via legacy classes (.user/.assistant) or the
+ // reflected data-sender attribute under @scope.
assistant: {
backgroundColor: colorVars['--color-neutral'],
color: colorVars['--color-text-primary'],
@@ -275,7 +277,7 @@ export function XDSChatMessageBubble({
ref={ref}
data-testid={testId}
{...mergeProps(
- xdsClassName('chat-message-bubble', {sender, variant, density}),
+ xdsThemeProps('chat-message-bubble', {sender, variant, density}),
stylex.props(
styles.content,
density === 'compact' && styles.radiusCompact,
diff --git a/packages/core/src/Chat/XDSChatMessageList.tsx b/packages/core/src/Chat/XDSChatMessageList.tsx
index 9a8c89f269..8336cefe3f 100644
--- a/packages/core/src/Chat/XDSChatMessageList.tsx
+++ b/packages/core/src/Chat/XDSChatMessageList.tsx
@@ -30,10 +30,11 @@ import {
type XDSChatDensity,
useXDSChatLayoutContext,
} from './XDSChatContext';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {XDSSpinner} from '../Spinner';
import type {XDSBaseProps} from '../XDSBaseProps';
import type {SpacingStep} from '../utils/types';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
export interface XDSChatMessageListProps extends XDSBaseProps<HTMLDivElement> {
/** Ref forwarded to the root element */
@@ -254,7 +255,7 @@ export function XDSChatMessageList({
tabIndex={0}
data-testid={testId}
{...mergeProps(
- xdsClassName('chat-message-list', {density}),
+ xdsThemeProps('chat-message-list', {density}),
stylex.props(styles.root, xstyle),
className,
style,
diff --git a/packages/core/src/Chat/XDSChatMessageMetadata.tsx b/packages/core/src/Chat/XDSChatMessageMetadata.tsx
index c343d1fa72..910cd66214 100644
--- a/packages/core/src/Chat/XDSChatMessageMetadata.tsx
+++ b/packages/core/src/Chat/XDSChatMessageMetadata.tsx
@@ -23,8 +23,9 @@ import {
import {useXDSChatMessageContext} from './XDSChatContext';
import {XDSIcon} from '../Icon';
import type {XDSIconName} from '../Icon/globalIconRegistry';
-import {mergeProps, xdsClassName} from '../utils';
+import {mergeProps} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
export type XDSChatMessageStatus =
| 'sending'
@@ -133,7 +134,7 @@ export function XDSChatMessageMetadata({
<div
ref={ref}
{...mergeProps(
- xdsClassName('chat-message-metadata'),
+ xdsThemeProps('chat-message-metadata'),
stylex.props(
styles.meta,
sender === 'user' ? styles.metaUser : styles.metaAssistant,
diff --git a/packages/core/src/Chat/XDSChatSendButton.tsx b/packages/core/src/Chat/XDSChatSendButton.tsx
index 0f8662639a..3207179a99 100644
--- a/packages/core/src/Chat/XDSChatSendButton.tsx
+++ b/packages/core/src/Chat/XDSChatSendButton.tsx
@@ -22,8 +22,9 @@ import * as stylex from '@stylexjs/stylex';
import {XDSButton} from '../Button';
import {getIcon} from '../Icon/globalIconRegistry';
import {useXDSChatComposerContext} from './XDSChatContext';
-import {xdsClassName} from '../utils';
+
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Types
@@ -104,7 +105,7 @@ export function XDSChatSendButton(props: XDSChatSendButtonProps): ReactNode {
isIconOnly
isDisabled={!isStopShown && isDisabled}
onClick={isStopShown ? onStop : handleSend}
- className={xdsClassName('chat-send-button')}
+ {...xdsThemeProps('chat-send-button')}
xstyle={[styles.root, xstyle]}
/>
);
diff --git a/packages/core/src/Chat/XDSChatSystemMessage.tsx b/packages/core/src/Chat/XDSChatSystemMessage.tsx
index 725a05027c..05e41af94c 100644
--- a/packages/core/src/Chat/XDSChatSystemMessage.tsx
+++ b/packages/core/src/Chat/XDSChatSystemMessage.tsx
@@ -28,9 +28,10 @@ import {
fontWeightVars,
typographyVars,
} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {XDSDivider} from '../Divider';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
export type XDSChatSystemMessageVariant = 'default' | 'divider';
@@ -129,7 +130,7 @@ export function XDSChatSystemMessage({
role="status"
data-testid={testId}
{...mergeProps(
- xdsClassName('chat-system-message', {variant}),
+ xdsThemeProps('chat-system-message', {variant}),
stylex.props(styles.dividerWrap, xstyle),
className,
styleProp,
@@ -145,7 +146,7 @@ export function XDSChatSystemMessage({
role="status"
data-testid={testId}
{...mergeProps(
- xdsClassName('chat-system-message', {variant}),
+ xdsThemeProps('chat-system-message', {variant}),
stylex.props(styles.root, xstyle),
className,
styleProp,
diff --git a/packages/core/src/Chat/XDSChatTokenizedText.tsx b/packages/core/src/Chat/XDSChatTokenizedText.tsx
index c3741651a2..f32a7a1bc0 100644
--- a/packages/core/src/Chat/XDSChatTokenizedText.tsx
+++ b/packages/core/src/Chat/XDSChatTokenizedText.tsx
@@ -21,8 +21,9 @@ import React, {type ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import {XDSBadge} from '../Badge';
import type {XDSChatComposerToken} from './XDSChatComposerInput';
-import {mergeProps, xdsClassName} from '../utils';
+import {mergeProps} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Styles
@@ -96,7 +97,7 @@ export function XDSChatTokenizedText({
<span
ref={ref}
{...mergeProps(
- xdsClassName('chat-tokenized-text'),
+ xdsThemeProps('chat-tokenized-text'),
stylex.props(styles.root),
)}>
{children ?? ''}
@@ -109,7 +110,7 @@ export function XDSChatTokenizedText({
<span
ref={ref}
{...mergeProps(
- xdsClassName('chat-tokenized-text'),
+ xdsThemeProps('chat-tokenized-text'),
stylex.props(styles.root),
)}>
{parts}
diff --git a/packages/core/src/Chat/XDSChatToolCalls.tsx b/packages/core/src/Chat/XDSChatToolCalls.tsx
index e260ddfcdf..650890f06f 100644
--- a/packages/core/src/Chat/XDSChatToolCalls.tsx
+++ b/packages/core/src/Chat/XDSChatToolCalls.tsx
@@ -31,10 +31,11 @@ import {
durationVars,
easeVars,
} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {XDSBadge} from '../Badge';
import {XDSIcon, type XDSIconName} from '../Icon';
import {XDSSpinner} from '../Spinner';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Types
@@ -502,7 +503,7 @@ export function XDSChatToolCalls(props: XDSChatToolCallsProps) {
<div
ref={ref}
{...mergeProps(
- xdsClassName('chat-tool-calls'),
+ xdsThemeProps('chat-tool-calls'),
stylex.props(styles.root, xstyle),
className,
style,
@@ -521,7 +522,7 @@ export function XDSChatToolCalls(props: XDSChatToolCallsProps) {
<div
ref={ref}
{...mergeProps(
- xdsClassName('chat-tool-calls'),
+ xdsThemeProps('chat-tool-calls'),
stylex.props(styles.root, xstyle),
className,
style,
diff --git a/packages/core/src/Chat/useTriggerMenu.tsx b/packages/core/src/Chat/useTriggerMenu.tsx
index 4679095c3b..c5541fb7de 100644
--- a/packages/core/src/Chat/useTriggerMenu.tsx
+++ b/packages/core/src/Chat/useTriggerMenu.tsx
@@ -37,8 +37,9 @@ import {
typeScaleVars,
typographyVars,
} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps, groupItems} from '../utils';
+import {mergeProps, groupItems} from '../utils';
import type {XDSSearchableItem} from '../Typeahead/types';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
import type {
XDSChatComposerTrigger,
XDSChatComposerToken,
@@ -683,7 +684,7 @@ export function useTriggerMenu(
role="listbox"
aria-label={trigger?.menuLabel ?? 'Suggestions'}
{...mergeProps(
- xdsClassName('trigger-menu'),
+ xdsThemeProps('trigger-menu'),
stylex.props(styles.dropdown),
)}>
{listContent}
diff --git a/packages/core/src/CheckboxInput/XDSCheckboxInput.tsx b/packages/core/src/CheckboxInput/XDSCheckboxInput.tsx
index 24bb763911..3e33b1d983 100644
--- a/packages/core/src/CheckboxInput/XDSCheckboxInput.tsx
+++ b/packages/core/src/CheckboxInput/XDSCheckboxInput.tsx
@@ -43,8 +43,9 @@ import {XDSFieldStatus} from '../FieldStatus/XDSFieldStatus';
import type {XDSIconType} from '../Icon';
import type {XDSInputStatus} from '../Field/types';
import {XDSSpinner} from '../Spinner';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import {checkboxScope} from './checkbox.markers.stylex';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const styles = stylex.create({
container: {
@@ -381,7 +382,7 @@ export function XDSCheckboxInput({
return (
<div
{...mergeProps(
- xdsClassName('checkbox-input', {size}),
+ xdsThemeProps('checkbox-input', {size}),
stylex.props(xstyle),
className,
style,
@@ -430,7 +431,7 @@ export function XDSCheckboxInput({
<div
aria-hidden="true"
{...mergeProps(
- xdsClassName('checkbox', {
+ xdsThemeProps('checkbox', {
size,
checked: isChecked
? 'checked'
diff --git a/packages/core/src/CheckboxList/XDSCheckboxList.tsx b/packages/core/src/CheckboxList/XDSCheckboxList.tsx
index 896e51fdc4..63d2bdc58c 100644
--- a/packages/core/src/CheckboxList/XDSCheckboxList.tsx
+++ b/packages/core/src/CheckboxList/XDSCheckboxList.tsx
@@ -29,7 +29,8 @@ import {XDSField} from '../Field/XDSField';
import type {XDSInputStatus} from '../Field/types';
import {XDSList} from '../List/XDSList';
import type {XDSListDensity} from '../List/XDSListContext';
-import {xdsClassName} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
import {
XDSCheckboxListContext,
type XDSCheckboxListContextValue,
@@ -207,10 +208,7 @@ export function XDSCheckboxList({
}
statusVariant="detached"
xstyle={xstyle}
- className={
- xdsClassName('checkbox-list') + (className ? ` ${className}` : '')
- }
- style={style}>
+ {...mergeProps(xdsThemeProps('checkbox-list'), {className, style})}>
<XDSCheckboxListContext value={contextValue}>
<XDSList density={density} hasDividers={hasDividers}>
{children}
diff --git a/packages/core/src/Citation/XDSCitation.tsx b/packages/core/src/Citation/XDSCitation.tsx
index 2d54506e04..c8d72eb31a 100644
--- a/packages/core/src/Citation/XDSCitation.tsx
+++ b/packages/core/src/Citation/XDSCitation.tsx
@@ -25,8 +25,9 @@ import {
durationVars,
easeVars,
} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
export interface XDSCitationSource {
title?: string;
@@ -172,7 +173,7 @@ export function XDSCitation({
data-testid={testId}
{...linkProps}
{...mergeProps(
- xdsClassName('citation', {variant}),
+ xdsThemeProps('citation', {variant}),
stylex.props(
styles.number,
href != null && styles.numberHover,
@@ -195,7 +196,7 @@ export function XDSCitation({
data-testid={testId}
{...linkProps}
{...mergeProps(
- xdsClassName('citation', {variant}),
+ xdsThemeProps('citation', {variant}),
stylex.props(
styles.label,
icon != null && styles.labelWithIcon,
diff --git a/packages/core/src/ClickableCard/XDSClickableCard.tsx b/packages/core/src/ClickableCard/XDSClickableCard.tsx
index 650cd03177..09f140babb 100644
--- a/packages/core/src/ClickableCard/XDSClickableCard.tsx
+++ b/packages/core/src/ClickableCard/XDSClickableCard.tsx
@@ -33,12 +33,13 @@ import * as stylex from '@stylexjs/stylex';
import type {StyleXStyles} from '@stylexjs/stylex';
import {colorVars, durationVars, easeVars} from '../theme/tokens.stylex';
import type {SizeValue, SpacingStep} from '../utils/types';
-import {xdsClassName, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import {XDSCard} from '../Card/XDSCard';
import type {XDSCardVariant} from '../Card/XDSCard';
import {useClickableContainer} from '../hooks/useClickableContainer';
import type {XDSBaseProps} from '../XDSBaseProps';
import {useXDSLinkComponent} from '../Link/useXDSLinkComponent';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Styles — only the interactive layer, Card handles everything else
@@ -255,11 +256,10 @@ export function XDSClickableCard({
maxWidth={maxWidth}
padding={padding}
variant={variant}
- className={
- classNameProp
- ? `${xdsClassName('clickable-card', {variant})} ${classNameProp}`
- : xdsClassName('clickable-card', {variant})
- }
+ {...mergeProps(xdsThemeProps('clickable-card', {variant}), {
+ className: classNameProp,
+ style,
+ })}
xstyle={
[
styles.interactive,
@@ -270,7 +270,6 @@ export function XDSClickableCard({
xstyleProp,
] as unknown as StyleXStyles
}
- style={style}
onClick={!isDisabled ? onClick : undefined}
onMouseUp={!isDisabled ? handleMouseUp : undefined}
{...props}>
diff --git a/packages/core/src/Code/XDSCode.tsx b/packages/core/src/Code/XDSCode.tsx
index ea3a507193..f5b441d9d8 100644
--- a/packages/core/src/Code/XDSCode.tsx
+++ b/packages/core/src/Code/XDSCode.tsx
@@ -23,8 +23,9 @@ import {
typographyVars,
typeScaleVars,
} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const styles = stylex.create({
base: {
@@ -73,7 +74,7 @@ export function XDSCode({
<code
ref={ref}
{...mergeProps(
- xdsClassName('code'),
+ xdsThemeProps('code'),
stylex.props(styles.base, xstyle),
className,
style,
diff --git a/packages/core/src/CodeBlock/XDSCodeBlock.tsx b/packages/core/src/CodeBlock/XDSCodeBlock.tsx
index 6a3306b42d..935886c1d0 100644
--- a/packages/core/src/CodeBlock/XDSCodeBlock.tsx
+++ b/packages/core/src/CodeBlock/XDSCodeBlock.tsx
@@ -31,7 +31,7 @@ import {
durationVars,
easeVars,
} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {XDSIcon} from '../Icon';
import {
tokenize,
@@ -42,6 +42,7 @@ import {
import type {Token, TokenLine} from './tokenizer';
import {ensureHighlightStyles} from './highlightStyles';
import {applyHighlightRangesChunked} from './highlightRanges';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// ---------------------------------------------------------------------------
// Styles
@@ -775,7 +776,7 @@ export function XDSCodeBlock({
<pre
ref={ref}
{...mergeProps(
- xdsClassName('codeblock', {size, language, container}),
+ xdsThemeProps('codeblock', {size, language, container}),
stylex.props(
styles.root,
dynamicStyles.width(widthProp),
diff --git a/packages/core/src/Collapsible/XDSCollapsible.tsx b/packages/core/src/Collapsible/XDSCollapsible.tsx
index d21ae44327..9c36925851 100644
--- a/packages/core/src/Collapsible/XDSCollapsible.tsx
+++ b/packages/core/src/Collapsible/XDSCollapsible.tsx
@@ -34,8 +34,9 @@ import {
} from '../theme/tokens.stylex';
import {useXDSCollapsible} from './useXDSCollapsible';
import {getIcon} from '../Icon/globalIconRegistry';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const styles = stylex.create({
root: {
@@ -197,7 +198,7 @@ export function XDSCollapsible({
<div
ref={ref}
{...mergeProps(
- xdsClassName('collapsible'),
+ xdsThemeProps('collapsible'),
stylex.props(styles.root, xstyle),
className,
style,
diff --git a/packages/core/src/CommandPalette/XDSCommandPaletteFooter.tsx b/packages/core/src/CommandPalette/XDSCommandPaletteFooter.tsx
index 69475247ec..b974fc4640 100644
--- a/packages/core/src/CommandPalette/XDSCommandPaletteFooter.tsx
+++ b/packages/core/src/CommandPalette/XDSCommandPaletteFooter.tsx
@@ -15,7 +15,7 @@
import type {ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import type {XDSBaseProps} from '../XDSBaseProps';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {
colorVars,
spacingVars,
@@ -23,6 +23,7 @@ import {
typographyVars,
} from '../theme/tokens.stylex';
import {XDSKbd} from '../Kbd';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const styles = stylex.create({
footer: {
@@ -88,7 +89,7 @@ export function XDSCommandPaletteFooter({
<div
ref={ref}
{...mergeProps(
- xdsClassName('command-palette-footer'),
+ xdsThemeProps('command-palette-footer'),
stylex.props(styles.footer, xstyle),
className,
style,
diff --git a/packages/core/src/CommandPalette/XDSCommandPaletteGroup.tsx b/packages/core/src/CommandPalette/XDSCommandPaletteGroup.tsx
index 80f9bdc87c..30377bb576 100644
--- a/packages/core/src/CommandPalette/XDSCommandPaletteGroup.tsx
+++ b/packages/core/src/CommandPalette/XDSCommandPaletteGroup.tsx
@@ -15,7 +15,8 @@
import type {ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import type {XDSBaseProps} from '../XDSBaseProps';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
import {
colorVars,
spacingVars,
@@ -83,7 +84,7 @@ export function XDSCommandPaletteGroup({
role="group"
aria-label={heading}
{...mergeProps(
- xdsClassName('command-palette-group'),
+ xdsThemeProps('command-palette-group'),
stylex.props(styles.group, xstyle),
className,
style,
diff --git a/packages/core/src/CommandPalette/XDSCommandPaletteInput.tsx b/packages/core/src/CommandPalette/XDSCommandPaletteInput.tsx
index 50d4d9156e..28414872bd 100644
--- a/packages/core/src/CommandPalette/XDSCommandPaletteInput.tsx
+++ b/packages/core/src/CommandPalette/XDSCommandPaletteInput.tsx
@@ -16,7 +16,7 @@ import {useCallback, useEffect, useRef, type ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import {XDSIcon} from '../Icon';
import {XDSSpinner} from '../Spinner';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import {
colorVars,
typeScaleVars,
@@ -26,6 +26,7 @@ import {
import {useCommandPaletteContext} from './CommandPaletteContext';
import {useDialogContext} from '../Dialog/DialogContext';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const styles = stylex.create({
wrapper: {
@@ -192,7 +193,7 @@ export function XDSCommandPaletteInput({
return (
<div
{...mergeProps(
- xdsClassName('command-palette-input'),
+ xdsThemeProps('command-palette-input'),
stylex.props(styles.wrapper, xstyle),
)}>
<span {...stylex.props(styles.icon)}>
diff --git a/packages/core/src/CommandPalette/XDSCommandPaletteItem.tsx b/packages/core/src/CommandPalette/XDSCommandPaletteItem.tsx
index bf9ec18f0a..a4950ebbad 100644
--- a/packages/core/src/CommandPalette/XDSCommandPaletteItem.tsx
+++ b/packages/core/src/CommandPalette/XDSCommandPaletteItem.tsx
@@ -14,7 +14,7 @@
import {useCallback, useEffect, useMemo, useRef, type ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import type {XDSBaseProps} from '../XDSBaseProps';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import {
colorVars,
spacingVars,
@@ -23,6 +23,7 @@ import {
typeScaleVars,
} from '../theme/tokens.stylex';
import {useCommandPaletteContext} from './CommandPaletteContext';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const HOVER_HOVER = '@media (hover: hover)';
@@ -178,7 +179,7 @@ export function XDSCommandPaletteItem({
onClick={handleClick}
onMouseEnter={handleMouseEnter}
{...mergeProps(
- xdsClassName('command-palette-item'),
+ xdsThemeProps('command-palette-item'),
stylex.props(
styles.item,
!isDisabled && styles.itemHover,
diff --git a/packages/core/src/CommandPalette/XDSCommandPaletteList.tsx b/packages/core/src/CommandPalette/XDSCommandPaletteList.tsx
index 40f0dae293..0ca21316e3 100644
--- a/packages/core/src/CommandPalette/XDSCommandPaletteList.tsx
+++ b/packages/core/src/CommandPalette/XDSCommandPaletteList.tsx
@@ -16,9 +16,10 @@
import type {ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import type {XDSBaseProps} from '../XDSBaseProps';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {spacingVars} from '../theme/tokens.stylex';
import {useCommandPaletteContext} from './CommandPaletteContext';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const styles = stylex.create({
list: {
@@ -87,7 +88,7 @@ export function XDSCommandPaletteList({
role="listbox"
aria-label={label}
{...mergeProps(
- xdsClassName('command-palette-list'),
+ xdsThemeProps('command-palette-list'),
stylex.props(styles.list, xstyle),
className,
style,
diff --git a/packages/core/src/ContextMenu/XDSContextMenu.tsx b/packages/core/src/ContextMenu/XDSContextMenu.tsx
index b2f6a228a1..d6862ca32f 100644
--- a/packages/core/src/ContextMenu/XDSContextMenu.tsx
+++ b/packages/core/src/ContextMenu/XDSContextMenu.tsx
@@ -51,8 +51,9 @@ import {
easeVars,
shadowVars,
} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
import type {
XDSDropdownMenuOption,
XDSDropdownMenuItemData,
@@ -187,7 +188,7 @@ export function XDSContextMenu({
const menuId = useId();
const positionRef = useRef({x: 0, y: 0});
- // eslint-disable-next-line @eslint-react/no-unused-state -- isOpen triggers the click-outside effect
+
const [isOpen, setIsOpen] = useState(false);
const layer = useXDSLayer({
@@ -296,7 +297,7 @@ export function XDSContextMenu({
role="menu"
onKeyDown={listKeyDown}
{...mergeProps(
- xdsClassName('context-menu'),
+ xdsThemeProps('context-menu'),
stylex.props(styles.menu, xstyle),
className,
style,
diff --git a/packages/core/src/DateInput/XDSDateInput.tsx b/packages/core/src/DateInput/XDSDateInput.tsx
index e29d8f2557..05b99ec106 100644
--- a/packages/core/src/DateInput/XDSDateInput.tsx
+++ b/packages/core/src/DateInput/XDSDateInput.tsx
@@ -132,8 +132,9 @@ export type {
XDSInputStatus as XDSDateInputStatus,
XDSInputStatusType as XDSDateInputStatusType,
} from '../Field';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
export interface XDSDateInputProps extends Omit<
XDSBaseProps,
@@ -506,7 +507,7 @@ export function XDSDateInput({
ref={popover.triggerRef}
{...rest}
{...mergeProps(
- xdsClassName('date-input', {size, status: status?.type ?? null}),
+ xdsThemeProps('date-input', {size, status: status?.type ?? null}),
stylex.props(
inputWrapperStyles.base,
sizeStyles[size],
diff --git a/packages/core/src/DateRangeInput/XDSDateRangeInput.tsx b/packages/core/src/DateRangeInput/XDSDateRangeInput.tsx
index 7c9e05b964..2a7a090ae3 100644
--- a/packages/core/src/DateRangeInput/XDSDateRangeInput.tsx
+++ b/packages/core/src/DateRangeInput/XDSDateRangeInput.tsx
@@ -48,10 +48,11 @@ import {XDSIcon} from '../Icon';
import {XDSSpinner} from '../Spinner';
import {XDSCalendar, type ISODateString, type DateRange} from '../Calendar';
import {useXDSPopover} from '../Popover';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {StyleXStyles} from '@stylexjs/stylex';
import type {XDSBaseProps} from '../XDSBaseProps';
import {useXDSSize} from '../SizeContext/XDSSizeContext';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
export type {DateRange as XDSDateRange} from '../Calendar';
@@ -486,7 +487,7 @@ export function XDSDateRangeInput({
ref={popover.triggerRef}
{...rest}
{...mergeProps(
- xdsClassName('date-range-input', {
+ xdsThemeProps('date-range-input', {
size,
status: status?.type ?? null,
}),
diff --git a/packages/core/src/DateTimeInput/XDSDateTimeInput.tsx b/packages/core/src/DateTimeInput/XDSDateTimeInput.tsx
index b22074bfda..e3f30fe37f 100644
--- a/packages/core/src/DateTimeInput/XDSDateTimeInput.tsx
+++ b/packages/core/src/DateTimeInput/XDSDateTimeInput.tsx
@@ -65,7 +65,6 @@ import {
formatISOTime,
isTimeInRange,
adjustTime,
- xdsClassName,
mergeProps,
mergeRefs,
} from '../utils';
@@ -78,6 +77,7 @@ import {
import type {StyleXStyles} from '@stylexjs/stylex';
import type {XDSBaseProps} from '../XDSBaseProps';
import {useXDSSize} from '../SizeContext/XDSSizeContext';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
export type ISODateTimeString = string & {
readonly __brand: 'ISODateTimeString';
@@ -781,7 +781,7 @@ export function XDSDateTimeInput({
<div
{...rest}
{...mergeProps(
- xdsClassName('date-time-input', {
+ xdsThemeProps('date-time-input', {
size,
status: status?.type ?? null,
}),
diff --git a/packages/core/src/Dialog/XDSDialog.tsx b/packages/core/src/Dialog/XDSDialog.tsx
index c7f402b8c1..ca77161382 100644
--- a/packages/core/src/Dialog/XDSDialog.tsx
+++ b/packages/core/src/Dialog/XDSDialog.tsx
@@ -37,8 +37,9 @@ import {
spacingStepToToken,
} from '../Layout/padding.stylex';
import type {SpacingStep} from '../utils/types';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import {DialogContext} from './DialogContext';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
/**
* Calculate a directional translate offset for dialog entry animation.
@@ -504,7 +505,7 @@ export function XDSDialog({
return (
<div
{...mergeProps(
- xdsClassName('dialog', {variant}),
+ xdsThemeProps('dialog', {variant}),
stylex.props(
styles.inlineWrapper,
!isFullscreen && dynamicStyles.sizing(width, maxHeight),
@@ -538,7 +539,7 @@ export function XDSDialog({
aria-modal="true"
role={purpose === 'required' ? 'alertdialog' : undefined}
{...mergeProps(
- xdsClassName('dialog', {variant}),
+ xdsThemeProps('dialog', {variant}),
stylex.props(
styles.dialog,
isOpen && styles.open,
diff --git a/packages/core/src/Divider/XDSDivider.tsx b/packages/core/src/Divider/XDSDivider.tsx
index dcea5f0ee9..28c154eaf3 100644
--- a/packages/core/src/Divider/XDSDivider.tsx
+++ b/packages/core/src/Divider/XDSDivider.tsx
@@ -25,7 +25,8 @@ import {
typeScaleVars,
borderVars,
} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
/**
* Extensible variant map for XDSDivider.
@@ -196,7 +197,7 @@ export function XDSDivider({
role="separator"
aria-orientation={orientation}
{...mergeProps(
- xdsClassName('divider', {variant, orientation}),
+ xdsThemeProps('divider', {variant, orientation}),
stylex.props(
isHorizontal ? baseStyles.horizontal : baseStyles.vertical,
isFullBleed &&
diff --git a/packages/core/src/DropdownMenu/XDSDropdownMenu.tsx b/packages/core/src/DropdownMenu/XDSDropdownMenu.tsx
index 48aa04e1bd..b9e121c0f2 100644
--- a/packages/core/src/DropdownMenu/XDSDropdownMenu.tsx
+++ b/packages/core/src/DropdownMenu/XDSDropdownMenu.tsx
@@ -51,8 +51,9 @@ import {
durationVars,
easeVars,
} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const styles = stylex.create({
dropdown: {
@@ -400,7 +401,7 @@ export function XDSDropdownMenu({
role="menu"
onKeyDown={listKeyDown}
{...mergeProps(
- xdsClassName('dropdown-menu'),
+ xdsThemeProps('dropdown-menu'),
stylex.props(styles.dropdown, xstyle),
className,
style,
diff --git a/packages/core/src/DropdownMenu/XDSDropdownMenuItem.tsx b/packages/core/src/DropdownMenu/XDSDropdownMenuItem.tsx
index a513cd21f7..8b2f58e9e2 100644
--- a/packages/core/src/DropdownMenu/XDSDropdownMenuItem.tsx
+++ b/packages/core/src/DropdownMenu/XDSDropdownMenuItem.tsx
@@ -33,8 +33,9 @@ import {
typographyVars,
typeScaleVars,
} from '../theme/tokens.stylex';
-import {xdsClassName} from '../utils';
+import {mergeProps} from '../utils';
import {useXDSDropdownMenuContext} from './XDSDropdownMenuContext';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const menuItemStyles = stylex.create({
root: {
@@ -159,13 +160,10 @@ export function XDSDropdownMenuItem({
isDisabled && menuItemStyles.disabled,
xstyle,
]}
- className={[
- xdsClassName('dropdown-menu-item', {size: menuSize}),
+ {...mergeProps(xdsThemeProps('dropdown-menu-item', {size: menuSize}), {
className,
- ]
- .filter(Boolean)
- .join(' ')}
- style={style}
+ style,
+ })}
/>
);
}
diff --git a/packages/core/src/EmptyState/XDSEmptyState.tsx b/packages/core/src/EmptyState/XDSEmptyState.tsx
index 19cee10b5c..574459423e 100644
--- a/packages/core/src/EmptyState/XDSEmptyState.tsx
+++ b/packages/core/src/EmptyState/XDSEmptyState.tsx
@@ -23,7 +23,8 @@ import {
typeScaleVars,
} from '../theme/tokens.stylex';
import type {XDSBaseProps} from '../XDSBaseProps';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const styles = stylex.create({
container: {
@@ -155,7 +156,7 @@ export function XDSEmptyState({
ref={ref}
role="status"
{...mergeProps(
- xdsClassName('emptystate', {variant: isCompact ? 'compact' : null}),
+ xdsThemeProps('emptystate', {variant: isCompact ? 'compact' : null}),
stylex.props(
styles.container,
isCompact && styles.containerCompact,
diff --git a/packages/core/src/Field/XDSField.tsx b/packages/core/src/Field/XDSField.tsx
index fe9e222cb2..ca94d7eecc 100644
--- a/packages/core/src/Field/XDSField.tsx
+++ b/packages/core/src/Field/XDSField.tsx
@@ -23,9 +23,10 @@ import {XDSFieldLabel} from './XDSFieldLabel';
import {XDSFieldStatus} from '../FieldStatus/XDSFieldStatus';
import {spacingVars, borderVars} from '../theme/tokens.stylex';
import type {XDSIconType} from '../Icon';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {XDSFormLayoutContext} from '../FormLayout/XDSFormLayoutContext';
import {XDSText} from '../Text';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const styles = stylex.create({
container: {
@@ -217,7 +218,7 @@ export function XDSField({
<div
ref={ref}
{...mergeProps(
- xdsClassName('field', {layout: 'horizontal-labels'}),
+ xdsThemeProps('field', {layout: 'horizontal-labels'}),
stylex.props(styles.horizontalLabels, xstyle),
className,
style,
@@ -245,7 +246,7 @@ export function XDSField({
<div
ref={ref}
{...mergeProps(
- xdsClassName('field'),
+ xdsThemeProps('field'),
stylex.props(
styles.container,
!isLabelHidden && styles.containerGap,
diff --git a/packages/core/src/Field/XDSFieldLabel.tsx b/packages/core/src/Field/XDSFieldLabel.tsx
index fc6a03f7d1..51f31d032c 100644
--- a/packages/core/src/Field/XDSFieldLabel.tsx
+++ b/packages/core/src/Field/XDSFieldLabel.tsx
@@ -15,7 +15,7 @@
import type {ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import type {XDSBaseProps} from '../XDSBaseProps';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {
colorVars,
@@ -26,6 +26,7 @@ import {
} from '../theme/tokens.stylex';
import {XDSIcon, renderIconSlot, type XDSIconType} from '../Icon';
import {XDSTooltip} from '../Tooltip';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const styles = stylex.create({
label: {
@@ -157,7 +158,7 @@ export function XDSFieldLabel({
ref={ref}
htmlFor={inputID}
{...mergeProps(
- xdsClassName('field-label'),
+ xdsThemeProps('field-label'),
stylex.props(
styles.label,
isDisabled && styles.labelDisabled,
diff --git a/packages/core/src/FieldStatus/XDSFieldStatus.tsx b/packages/core/src/FieldStatus/XDSFieldStatus.tsx
index b04a57db40..82b79ef2c0 100644
--- a/packages/core/src/FieldStatus/XDSFieldStatus.tsx
+++ b/packages/core/src/FieldStatus/XDSFieldStatus.tsx
@@ -19,7 +19,7 @@
import React from 'react';
import * as stylex from '@stylexjs/stylex';
import type {XDSBaseProps} from '../XDSBaseProps';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {
colorVars,
radiusVars,
@@ -29,6 +29,7 @@ import {
} from '../theme/tokens.stylex';
import type {XDSInputStatusType} from '../Field/types';
import {useEntryAnimation} from '../hooks/useEntryAnimation';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const styles = stylex.create({
base: {
@@ -141,7 +142,7 @@ export function XDSFieldStatus({
role={type === 'error' ? 'alert' : 'status'}
aria-live={type === 'error' ? 'assertive' : 'polite'}
{...mergeProps(
- xdsClassName('field-status', {type, variant}),
+ xdsThemeProps('field-status', {type, variant}),
stylex.props(
styles.base,
entryStyle,
diff --git a/packages/core/src/FileInput/XDSFileInput.tsx b/packages/core/src/FileInput/XDSFileInput.tsx
index 1e920a3ce0..f26ffdcebf 100644
--- a/packages/core/src/FileInput/XDSFileInput.tsx
+++ b/packages/core/src/FileInput/XDSFileInput.tsx
@@ -49,8 +49,9 @@ export type {
XDSInputStatus as XDSFileInputStatus,
XDSInputStatusType as XDSFileInputStatusType,
} from '../Field';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
function formatFileSize(bytes: number): string {
if (bytes < 1024) {
@@ -664,7 +665,7 @@ export function XDSFileInput({
aria-busy={isLoading || undefined}
{...dragDropProps}
{...mergeProps(
- xdsClassName('file-input', {mode, status: status?.type ?? null}),
+ xdsThemeProps('file-input', {mode, status: status?.type ?? null}),
stylex.props(
isDropzone ? styles.dropzone : styles.compact,
isDropzone && !isDisabled && styles.dropzoneHover,
diff --git a/packages/core/src/FormLayout/XDSFormLayout.tsx b/packages/core/src/FormLayout/XDSFormLayout.tsx
index 72b124038c..7e2d5e70e2 100644
--- a/packages/core/src/FormLayout/XDSFormLayout.tsx
+++ b/packages/core/src/FormLayout/XDSFormLayout.tsx
@@ -24,7 +24,8 @@ import {
XDSFormLayoutContext,
type XDSFormLayoutDirection,
} from './XDSFormLayoutContext';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Responsive breakpoint for horizontal-labels collapse
@@ -147,7 +148,7 @@ export function XDSFormLayout({
<div
ref={ref}
{...mergeProps(
- xdsClassName('form-layout', {direction}),
+ xdsThemeProps('form-layout', {direction}),
stylex.props(
styles.base,
direction === 'horizontal' && styles.horizontal,
diff --git a/packages/core/src/FormLayout/__snapshots__/XDSFormLayout.test.tsx.snap b/packages/core/src/FormLayout/__snapshots__/XDSFormLayout.test.tsx.snap
index 08c1ff0c57..faa66bc593 100644
--- a/packages/core/src/FormLayout/__snapshots__/XDSFormLayout.test.tsx.snap
+++ b/packages/core/src/FormLayout/__snapshots__/XDSFormLayout.test.tsx.snap
@@ -3,6 +3,8 @@
exports[`XDSFormLayout > matches snapshot for horizontal direction 1`] = `
<div
class="xds-form-layout horizontal XDSFormLayout__styles.base xdt5ytf x18g69wz XDSFormLayout__styles.horizontal xrvj5dj x1mt1orb xu6a5m6"
+ data-direction="horizontal"
+ data-style-src="@xds/core:src/FormLayout/XDSFormLayout.tsx:41; @xds/core:src/FormLayout/XDSFormLayout.tsx:46"
data-testid="layout"
>
<input
@@ -17,6 +19,8 @@ exports[`XDSFormLayout > matches snapshot for horizontal direction 1`] = `
exports[`XDSFormLayout > matches snapshot for horizontal-labels direction 1`] = `
<div
class="xds-form-layout horizontal-labels XDSFormLayout__styles.base xdt5ytf XDSFormLayout__styles.horizontalLabels xrvj5dj x1pmbctz xlaq8a2 x7a106z xedohl4 x1rpgqan x1a1jff"
+ data-direction="horizontal-labels"
+ data-style-src="@xds/core:src/FormLayout/XDSFormLayout.tsx:41; @xds/core:src/FormLayout/XDSFormLayout.tsx:51"
data-testid="layout"
>
<label>
@@ -31,6 +35,8 @@ exports[`XDSFormLayout > matches snapshot for horizontal-labels direction 1`] =
exports[`XDSFormLayout > matches snapshot for vertical direction 1`] = `
<div
class="xds-form-layout vertical XDSFormLayout__styles.base x78zum5 xdt5ytf x18g69wz"
+ data-direction="vertical"
+ data-style-src="@xds/core:src/FormLayout/XDSFormLayout.tsx:41"
data-testid="layout"
>
<input
diff --git a/packages/core/src/Grid/XDSGrid.tsx b/packages/core/src/Grid/XDSGrid.tsx
index 8b1979b0cc..0531b00d3a 100644
--- a/packages/core/src/Grid/XDSGrid.tsx
+++ b/packages/core/src/Grid/XDSGrid.tsx
@@ -22,7 +22,8 @@ import type {StyleXStyles} from '@stylexjs/stylex';
import {spacingVars} from '../theme/tokens.stylex';
import type {SpacingStep} from '../utils/types';
import type {SizeValue} from '../utils/types';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
/**
* Grid alignment options for align-items and justify-items.
@@ -433,7 +434,7 @@ export function XDSGrid({
}),
};
- // For xdsClassName, extract numeric columns value for variant tracking
+ // For xdsThemeProps, extract numeric columns value for variant tracking
const columnsVariant =
typeof columns === 'number'
? columns
@@ -445,7 +446,7 @@ export function XDSGrid({
<div
ref={ref}
{...mergeProps(
- xdsClassName('grid', {columns: columnsVariant, gap, align, justify}),
+ xdsThemeProps('grid', {columns: columnsVariant, gap, align, justify}),
stylex.props(
baseStyles.grid,
gap != null && gapStyles[gap],
diff --git a/packages/core/src/Grid/XDSGridSpan.tsx b/packages/core/src/Grid/XDSGridSpan.tsx
index 2e0ea108b7..bbc41c6605 100644
--- a/packages/core/src/Grid/XDSGridSpan.tsx
+++ b/packages/core/src/Grid/XDSGridSpan.tsx
@@ -17,7 +17,8 @@ import type {ReactNode} from 'react';
import type {XDSBaseProps} from '../XDSBaseProps';
import * as stylex from '@stylexjs/stylex';
import type {StyleXStyles} from '@stylexjs/stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
export interface XDSGridSpanProps extends XDSBaseProps<HTMLDivElement> {
/** Ref forwarded to the root element */
@@ -111,7 +112,7 @@ export function XDSGridSpan({
<div
ref={ref}
{...mergeProps(
- xdsClassName('grid-span'),
+ xdsThemeProps('grid-span'),
stylex.props(baseStyles.span, xstyle),
className,
{...style, ...inlineStyle},
diff --git a/packages/core/src/Heading/XDSHeading.test.tsx b/packages/core/src/Heading/XDSHeading.test.tsx
index f02c506c7c..1b73264399 100644
--- a/packages/core/src/Heading/XDSHeading.test.tsx
+++ b/packages/core/src/Heading/XDSHeading.test.tsx
@@ -189,11 +189,18 @@ describe('XDSHeading', () => {
});
});
- it('renders xds-* class names for theme targeting', () => {
- render(<XDSHeading level={2}>Themed Heading</XDSHeading>);
+ it('renders xds-* classes and data attributes for theme targeting', () => {
+ render(
+ <XDSHeading level={2} color="secondary">
+ Themed Heading
+ </XDSHeading>,
+ );
const element = screen.getByText('Themed Heading');
expect(element.className).toContain('xds-heading');
expect(element.className).toContain('level-2');
+ expect(element.className).toContain('secondary');
+ expect(element).toHaveAttribute('data-level', '2');
+ expect(element).toHaveAttribute('data-color', 'secondary');
});
it('does not include variant in class names', () => {
diff --git a/packages/core/src/Heading/XDSHeading.tsx b/packages/core/src/Heading/XDSHeading.tsx
index 02acc0bef1..5d7730b646 100644
--- a/packages/core/src/Heading/XDSHeading.tsx
+++ b/packages/core/src/Heading/XDSHeading.tsx
@@ -42,8 +42,9 @@ import {
} from '../Text/text.stylex';
import {useTruncation} from '../Text/useTruncation';
import type {LayerPlacement} from '../Layer';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const LazyXDSTooltip = lazy(async () =>
import('../Tooltip/XDSTooltip').then(mod => ({default: mod.XDSTooltip})),
@@ -248,7 +249,7 @@ export function XDSHeading({
<Component
ref={mergeRefs(ref, truncation.ref, headingRef)}
{...mergeProps(
- xdsClassName('heading', {level, color, ...(type && {type})}),
+ xdsThemeProps('heading', {level, color, ...(type && {type})}),
stylex.props(
colorStyles[color],
type ? sizeByTypeStyles[type] : sizeByLevelStyles[level],
diff --git a/packages/core/src/HoverCard/useXDSHoverCard.tsx b/packages/core/src/HoverCard/useXDSHoverCard.tsx
index 8699d657b3..efc9d9bd8c 100644
--- a/packages/core/src/HoverCard/useXDSHoverCard.tsx
+++ b/packages/core/src/HoverCard/useXDSHoverCard.tsx
@@ -34,7 +34,8 @@ import {
radiusVars,
spacingVars,
} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const styles = stylex.create({
// Base container styles passed to useXDSLayer
@@ -458,7 +459,7 @@ export function useXDSHoverCard(
return layer.render(
<div
{...mergeProps(
- xdsClassName('hovercard'),
+ xdsThemeProps('hovercard'),
stylex.props(styles.content),
)}
onMouseEnter={() => {
diff --git a/packages/core/src/Icon/XDSIcon.tsx b/packages/core/src/Icon/XDSIcon.tsx
index 68398c72da..fd6ea35375 100644
--- a/packages/core/src/Icon/XDSIcon.tsx
+++ b/packages/core/src/Icon/XDSIcon.tsx
@@ -27,7 +27,8 @@ import * as stylex from '@stylexjs/stylex';
import {colorVars} from '../theme/tokens.stylex';
import {getIcon} from './globalIconRegistry';
import type {XDSIconName} from './globalIconRegistry';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Styles
@@ -233,7 +234,7 @@ export function XDSIcon({
ref={ref}
aria-hidden="true"
{...mergeProps(
- xdsClassName('icon', {size, color}),
+ xdsThemeProps('icon', {size, color}),
stylex.props(styles.root, colorStyles[color], sizeStyles[size]),
)}
{...props}
@@ -272,7 +273,7 @@ function IconFromRegistry({
return (
<span
{...mergeProps(
- xdsClassName('icon', {size, color}),
+ xdsThemeProps('icon', {size, color}),
stylex.props(styles.span, colorStyles[color], spanSizeStyles[size]),
)}
aria-hidden="true">
diff --git a/packages/core/src/InputGroup/XDSInputGroup.tsx b/packages/core/src/InputGroup/XDSInputGroup.tsx
index aff80099ae..5eda5db9c2 100644
--- a/packages/core/src/InputGroup/XDSInputGroup.tsx
+++ b/packages/core/src/InputGroup/XDSInputGroup.tsx
@@ -25,9 +25,10 @@ import * as stylex from '@stylexjs/stylex';
import {sizeVars} from '../theme/tokens.stylex';
import {XDSField, type XDSInputStatus} from '../Field';
import {XDSSizeProvider, useXDSSize} from '../SizeContext/XDSSizeContext';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
import {XDSInputGroupContext} from './XDSInputGroupContext';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
export type XDSInputGroupSize = 'sm' | 'md' | 'lg';
@@ -188,7 +189,7 @@ export function XDSInputGroup({
data-testid={testId}
{...rest}
{...mergeProps(
- xdsClassName('input-group', {
+ xdsThemeProps('input-group', {
size,
status: status?.type ?? null,
}),
diff --git a/packages/core/src/InputGroup/XDSInputGroupText.tsx b/packages/core/src/InputGroup/XDSInputGroupText.tsx
index 2ded5d8a2b..4623b43129 100644
--- a/packages/core/src/InputGroup/XDSInputGroupText.tsx
+++ b/packages/core/src/InputGroup/XDSInputGroupText.tsx
@@ -25,7 +25,8 @@ import {
typeScaleVars,
borderVars,
} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const styles = stylex.create({
text: {
@@ -96,7 +97,7 @@ export function XDSInputGroupText({
<div
ref={ref}
{...mergeProps(
- xdsClassName('input-group-text'),
+ xdsThemeProps('input-group-text'),
stylex.props(styles.text, xstyle),
className,
style,
diff --git a/packages/core/src/Item/XDSItem.tsx b/packages/core/src/Item/XDSItem.tsx
index 16a629d8f1..ad7fbb57b8 100644
--- a/packages/core/src/Item/XDSItem.tsx
+++ b/packages/core/src/Item/XDSItem.tsx
@@ -27,9 +27,10 @@ import {
typeScaleVars,
} from '../theme/tokens.stylex';
import type {XDSBaseProps} from '../XDSBaseProps';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {computeTargetAndRel} from '../Link/computeTargetAndRel';
import {useXDSLinkComponent} from '../Link/useXDSLinkComponent';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Types
@@ -473,7 +474,7 @@ export function XDSItem({
aria-disabled={isDisabled || undefined}
{...restProps}
{...mergeProps(
- xdsClassName('item', {density, align}),
+ xdsThemeProps('item', {density, align}),
stylex.props(
styles.root,
densityStyles[density],
diff --git a/packages/core/src/Kbd/XDSKbd.tsx b/packages/core/src/Kbd/XDSKbd.tsx
index 8ecf2073c6..c388fe46b1 100644
--- a/packages/core/src/Kbd/XDSKbd.tsx
+++ b/packages/core/src/Kbd/XDSKbd.tsx
@@ -15,8 +15,9 @@
import React, {useSyncExternalStore} from 'react';
import * as stylex from '@stylexjs/stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
import {
colorVars,
spacingVars,
@@ -166,7 +167,7 @@ export function XDSKbd({
ref={ref}
{...rest}
{...mergeProps(
- xdsClassName('kbd'),
+ xdsThemeProps('kbd'),
stylex.props(styles.wrapper, xstyle),
className,
style,
diff --git a/packages/core/src/Layer/useXDSLayer.tsx b/packages/core/src/Layer/useXDSLayer.tsx
index 10bc6f260e..fedc086a43 100644
--- a/packages/core/src/Layer/useXDSLayer.tsx
+++ b/packages/core/src/Layer/useXDSLayer.tsx
@@ -23,6 +23,7 @@ import React, {
} from 'react';
import * as stylex from '@stylexjs/stylex';
import type {StyleXStyles} from '@stylexjs/stylex';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// Extend React's HTMLAttributes to include popover API attributes
declare module 'react' {
@@ -77,7 +78,7 @@ export interface ContextRenderProps {
xstyle?: StyleXStyles;
/**
* Additional CSS class name(s) for the popover container.
- * Use with xdsClassName() for theme targeting.
+ * Use with xdsThemeProps() for theme targeting when reflecting visual props.
*/
className?: string;
/**
@@ -99,7 +100,7 @@ export interface FixedRenderProps {
xstyle?: StyleXStyles;
/**
* Additional CSS class name(s) for the popover container.
- * Use with xdsClassName() for theme targeting.
+ * Use with xdsThemeProps() for theme targeting when reflecting visual props.
*/
className?: string;
/**
diff --git a/packages/core/src/Layout/XDSLayout.tsx b/packages/core/src/Layout/XDSLayout.tsx
index f5d50dd6b7..4871f5ea81 100644
--- a/packages/core/src/Layout/XDSLayout.tsx
+++ b/packages/core/src/Layout/XDSLayout.tsx
@@ -24,9 +24,10 @@ import {XDSLayoutSlotsContext, type LayoutSlots} from './XDSLayoutSlotsContext';
import {XDSLayoutDividerContext} from './XDSLayoutDividerContext';
import {stack} from '../Stack/stack.stylex';
import {stackItem} from '../Stack/stackItem.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
import type {SpacingStep} from '../utils/types';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
import {
layoutPaddingOuterXVarStyles,
layoutPaddingOuterYVarStyles,
@@ -257,7 +258,7 @@ export function XDSLayout({
<div
ref={ref}
{...mergeProps(
- xdsClassName('layout', {height}),
+ xdsThemeProps('layout', {height}),
stylex.props(
styles.layoutOuter,
isFill ? styles.fill : styles.auto,
diff --git a/packages/core/src/Layout/XDSLayoutContent.tsx b/packages/core/src/Layout/XDSLayoutContent.tsx
index c8ff6bcb1b..94f0611a54 100644
--- a/packages/core/src/Layout/XDSLayoutContent.tsx
+++ b/packages/core/src/Layout/XDSLayoutContent.tsx
@@ -21,8 +21,9 @@ import {use} from 'react';
import * as stylex from '@stylexjs/stylex';
import {spacingVars} from '../theme/tokens.stylex';
import {XDSLayoutSlotsContext} from './XDSLayoutSlotsContext';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {SpacingStep} from '../utils/types';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
import {
paddingStyles,
containerPaddingInlineVarStyles,
@@ -185,7 +186,7 @@ export function XDSLayoutContent({
role={role}
aria-label={label}
{...mergeProps(
- xdsClassName('layout-content'),
+ xdsThemeProps('layout-content'),
stylex.props(
styles.content,
// Outer padding on container edges (unless content is full bleed)
diff --git a/packages/core/src/Layout/XDSLayoutFooter.tsx b/packages/core/src/Layout/XDSLayoutFooter.tsx
index 09c75f9371..e169d3665c 100644
--- a/packages/core/src/Layout/XDSLayoutFooter.tsx
+++ b/packages/core/src/Layout/XDSLayoutFooter.tsx
@@ -21,8 +21,9 @@ import {use} from 'react';
import * as stylex from '@stylexjs/stylex';
import {XDSLayoutDividerContext} from './XDSLayoutDividerContext';
import {colorVars, spacingVars} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {SpacingStep} from '../utils/types';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
import {
paddingStyles,
containerPaddingInlineVarStyles,
@@ -158,7 +159,7 @@ export function XDSLayoutFooter({
aria-label={label}
data-divider={resolvedHasDivider || undefined}
{...mergeProps(
- xdsClassName('layout-footer'),
+ xdsThemeProps('layout-footer'),
stylex.props(
styles.footer,
dynamicStyles.sizing(height ?? null),
diff --git a/packages/core/src/Layout/XDSLayoutHeader.tsx b/packages/core/src/Layout/XDSLayoutHeader.tsx
index bc85815259..8cc9a43df5 100644
--- a/packages/core/src/Layout/XDSLayoutHeader.tsx
+++ b/packages/core/src/Layout/XDSLayoutHeader.tsx
@@ -21,8 +21,9 @@ import {use} from 'react';
import * as stylex from '@stylexjs/stylex';
import {XDSLayoutDividerContext} from './XDSLayoutDividerContext';
import {colorVars, spacingVars} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {SpacingStep} from '../utils/types';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
import {
paddingStyles,
containerPaddingInlineVarStyles,
@@ -158,7 +159,7 @@ export function XDSLayoutHeader({
aria-label={label}
data-divider={resolvedHasDivider || undefined}
{...mergeProps(
- xdsClassName('layout-header'),
+ xdsThemeProps('layout-header'),
stylex.props(
styles.header,
dynamicStyles.sizing(height ?? null),
diff --git a/packages/core/src/Layout/XDSLayoutPanel.tsx b/packages/core/src/Layout/XDSLayoutPanel.tsx
index a91178617c..44813be3c7 100644
--- a/packages/core/src/Layout/XDSLayoutPanel.tsx
+++ b/packages/core/src/Layout/XDSLayoutPanel.tsx
@@ -22,9 +22,10 @@ import * as stylex from '@stylexjs/stylex';
import {colorVars, spacingVars} from '../theme/tokens.stylex';
import {XDSLayoutAreaContext} from './XDSLayoutAreaContext';
import {XDSLayoutSlotsContext} from './XDSLayoutSlotsContext';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {SpacingStep} from '../utils/types';
import type {ResizableProps} from '../Resizable/useXDSResizable';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
import {
paddingStyles,
containerPaddingInlineVarStyles,
@@ -255,7 +256,7 @@ export function XDSLayoutPanel({
role={role}
aria-label={label}
{...mergeProps(
- xdsClassName('layout-panel'),
+ xdsThemeProps('layout-panel'),
stylex.props(
styles.panel,
dynamicStyles.sizing(effectiveWidth ?? null),
diff --git a/packages/core/src/Lightbox/XDSLightbox.tsx b/packages/core/src/Lightbox/XDSLightbox.tsx
index 36a54919d7..2b5451eb88 100644
--- a/packages/core/src/Lightbox/XDSLightbox.tsx
+++ b/packages/core/src/Lightbox/XDSLightbox.tsx
@@ -30,8 +30,9 @@ import {XDSIcon} from '../Icon';
import {XDSIconButton} from '../IconButton';
import {useScrollLock} from '../hooks/useScrollLock';
import {useIsomorphicLayoutEffect} from '../hooks/useIsomorphicLayoutEffect';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
/**
* Media type for lightbox items.
@@ -477,7 +478,7 @@ export function XDSLightbox({
}}
aria-label={currentItem.alt || 'Media viewer'}
{...mergeProps(
- xdsClassName('lightbox'),
+ xdsThemeProps('lightbox'),
stylex.props(styles.dialog, xstyle),
className,
style,
diff --git a/packages/core/src/Link/XDSLink.tsx b/packages/core/src/Link/XDSLink.tsx
index 1929e50181..b24c74b430 100644
--- a/packages/core/src/Link/XDSLink.tsx
+++ b/packages/core/src/Link/XDSLink.tsx
@@ -39,9 +39,10 @@ import type {
} from '../theme/types';
import {useXDSLinkComponent} from './useXDSLinkComponent';
import type {XDSLinkComponentType} from './types';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {computeTargetAndRel} from './computeTargetAndRel';
import {useXDSInteractiveRole} from '../hooks/useXDSInteractiveRole';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
/**
* Base link styles
@@ -284,7 +285,8 @@ export function XDSLink({
// When role resolves to 'button' (no href, or context-provided),
// render as a <button> with link styling for semantic correctness.
- const renderAsButton = role === 'button' || (role === 'inert' && href == null);
+ const renderAsButton =
+ role === 'button' || (role === 'inert' && href == null);
const sharedContent = (
<>
@@ -316,7 +318,7 @@ export function XDSLink({
tabIndex={isDisabled ? -1 : undefined}
disabled={isDisabled}
{...mergeProps(
- xdsClassName('link', {color}),
+ xdsThemeProps('link', {color}),
stylex.props(
styles.base,
styles.buttonReset,
@@ -345,7 +347,7 @@ export function XDSLink({
aria-disabled={isDisabled || undefined}
tabIndex={isDisabled ? -1 : undefined}
{...mergeProps(
- xdsClassName('link', {color}),
+ xdsThemeProps('link', {color}),
stylex.props(
styles.base,
linkColorStyles[color],
diff --git a/packages/core/src/List/XDSList.tsx b/packages/core/src/List/XDSList.tsx
index 08ddf2b7c2..0787958e78 100644
--- a/packages/core/src/List/XDSList.tsx
+++ b/packages/core/src/List/XDSList.tsx
@@ -25,7 +25,8 @@ import {
type XDSListDensity,
type XDSListMarkerStyle,
} from './XDSListContext';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
export {
type XDSListDensity,
@@ -169,7 +170,7 @@ export function XDSList({
{...(isOrdered && start != null && start !== 1 ? {start} : {})}
{...(listStyle === 'none' && !isOrdered ? {role: 'list'} : {})}
{...mergeProps(
- xdsClassName('list', {density, listStyle}),
+ xdsThemeProps('list', {density, listStyle}),
stylex.props(
styles.list,
hasDividers && styles.withDividers,
diff --git a/packages/core/src/List/XDSListItem.tsx b/packages/core/src/List/XDSListItem.tsx
index f82188c42d..3ba80af704 100644
--- a/packages/core/src/List/XDSListItem.tsx
+++ b/packages/core/src/List/XDSListItem.tsx
@@ -29,8 +29,9 @@ import {
} from '../theme/tokens.stylex';
import type {XDSBaseProps} from '../XDSBaseProps';
import {XDSListContext} from './XDSListContext';
-import {xdsClassName} from '../utils';
+import {mergeProps} from '../utils';
import {XDSItem} from '../Item';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Types
@@ -250,10 +251,7 @@ export function XDSListItem({
hasDividers && embeddedStyles.noRadius,
xstyle,
]}
- className={[xdsClassName('list-item'), className]
- .filter(Boolean)
- .join(' ')}
- style={style}
+ {...mergeProps(xdsThemeProps('list-item'), {className, style})}
{...restProps}
/>
);
diff --git a/packages/core/src/Markdown/XDSMarkdown.tsx b/packages/core/src/Markdown/XDSMarkdown.tsx
index 21856c2288..ae92cc2e83 100644
--- a/packages/core/src/Markdown/XDSMarkdown.tsx
+++ b/packages/core/src/Markdown/XDSMarkdown.tsx
@@ -37,7 +37,7 @@ import {XDSTableCell} from '../Table/XDSTableCell';
import {XDSTableHeaderCell} from '../Table/XDSTableHeaderCell';
import {XDSTableHeader} from '../Table/XDSTableHeader';
import {XDSTableBody} from '../Table/XDSTableBody';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {useXDSStreamingText} from '../hooks/useXDSStreamingText';
import {computeBoundaries, computeSegments} from './streaming';
import type {XDSBaseProps} from '../XDSBaseProps';
@@ -53,6 +53,7 @@ import {
trimStreamingArtifacts,
} from './parser';
import type {BlockNode, InlineNode, IncrementalState} from './parser';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
type SyncReactNode = Exclude<React.ReactNode, Promise<unknown>>;
@@ -1618,7 +1619,7 @@ export function XDSMarkdown({
ref={ref}
data-testid={testId}
{...mergeProps(
- xdsClassName('markdown', {density}),
+ xdsThemeProps('markdown', {density}),
stylex.props(styles.root, xstyle),
className,
style,
diff --git a/packages/core/src/MetadataList/XDSMetadataList.tsx b/packages/core/src/MetadataList/XDSMetadataList.tsx
index 6713c161dd..dcc7d938fb 100644
--- a/packages/core/src/MetadataList/XDSMetadataList.tsx
+++ b/packages/core/src/MetadataList/XDSMetadataList.tsx
@@ -29,7 +29,8 @@ import {
type XDSMetadataListLabelConfig,
} from './XDSMetadataListContext';
import type {XDSBaseProps} from '../XDSBaseProps';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Types
@@ -259,7 +260,7 @@ export function XDSMetadataList({
ref={ref}
data-testid={testId}
{...mergeProps(
- xdsClassName('metadata-list', {
+ xdsThemeProps('metadata-list', {
columns: String(columns),
orientation,
}),
diff --git a/packages/core/src/MetadataList/XDSMetadataListItem.tsx b/packages/core/src/MetadataList/XDSMetadataListItem.tsx
index 1afc880ad6..914025a91b 100644
--- a/packages/core/src/MetadataList/XDSMetadataListItem.tsx
+++ b/packages/core/src/MetadataList/XDSMetadataListItem.tsx
@@ -26,7 +26,8 @@ import {
} from '../theme/tokens.stylex';
import {XDSMetadataListContext} from './XDSMetadataListContext';
import type {XDSBaseProps} from '../XDSBaseProps';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Types
@@ -165,7 +166,7 @@ export function XDSMetadataListItem({
ref={ref}
data-testid={testId}
{...mergeProps(
- xdsClassName('metadata-list-item'),
+ xdsThemeProps('metadata-list-item'),
stylex.props(styles.stackedWrapper, xstyle),
className,
style,
@@ -183,7 +184,7 @@ export function XDSMetadataListItem({
ref={ref}
data-testid={testId ? `${testId}-label` : undefined}
{...mergeProps(
- xdsClassName('metadata-list-item'),
+ xdsThemeProps('metadata-list-item'),
stylex.props(styles.label, xstyle),
className,
style,
diff --git a/packages/core/src/MobileNav/XDSMobileNav.tsx b/packages/core/src/MobileNav/XDSMobileNav.tsx
index 849e190609..e233670dca 100644
--- a/packages/core/src/MobileNav/XDSMobileNav.tsx
+++ b/packages/core/src/MobileNav/XDSMobileNav.tsx
@@ -46,8 +46,9 @@ import {XDSButton} from '../Button';
import {XDSIcon} from '../Icon';
import {XDSHeading} from '../Heading/XDSHeading';
import {useXDSAppShellMobile} from '../AppShell/XDSAppShellMobileContext';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Styles
@@ -398,7 +399,7 @@ export function XDSMobileNav({
onClick={handleDialogClick}
onCancel={handleCancel}
{...mergeProps(
- xdsClassName('mobile-nav', {side: resolvedSide}),
+ xdsThemeProps('mobile-nav', {side: resolvedSide}),
stylex.props(
styles.dialog,
isOpen && styles.open,
diff --git a/packages/core/src/MultiSelector/XDSMultiSelector.tsx b/packages/core/src/MultiSelector/XDSMultiSelector.tsx
index d3e57d0006..26e7be4a3f 100644
--- a/packages/core/src/MultiSelector/XDSMultiSelector.tsx
+++ b/packages/core/src/MultiSelector/XDSMultiSelector.tsx
@@ -64,9 +64,10 @@ import {
getSelectableOptions,
} from '../Selector/utils';
import {useMultiCombobox} from './hooks';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
import {useXDSSize} from '../SizeContext/XDSSizeContext';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// Sentinel value for the select-all item in keyboard navigation
const SELECT_ALL_VALUE = '__xds_select_all__';
@@ -1114,7 +1115,7 @@ export function XDSMultiSelector<T extends XDSMultiSelectorOptionType>({
onClick={onTriggerClick}
data-testid={testId}
{...mergeProps(
- xdsClassName('multi-selector', {size, status: status?.type ?? null}),
+ xdsThemeProps('multi-selector', {size, status: status?.type ?? null}),
stylex.props(
inputWrapperStyles.base,
styles.triggerContainer,
diff --git a/packages/core/src/NavIcon/XDSNavIcon.tsx b/packages/core/src/NavIcon/XDSNavIcon.tsx
index 608d9b1d91..8a2f476197 100644
--- a/packages/core/src/NavIcon/XDSNavIcon.tsx
+++ b/packages/core/src/NavIcon/XDSNavIcon.tsx
@@ -18,7 +18,8 @@ import type {ReactNode} from 'react';
import type {XDSBaseProps} from '../XDSBaseProps';
import * as stylex from '@stylexjs/stylex';
import {colorVars, sizeVars} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
/**
* NavIcon styles
@@ -78,7 +79,7 @@ export function XDSNavIcon({
<span
ref={ref}
{...mergeProps(
- xdsClassName('navicon'),
+ xdsThemeProps('navicon'),
stylex.props(styles.base, xstyle),
className,
style,
diff --git a/packages/core/src/NavMenu/XDSNavHeadingMenu.tsx b/packages/core/src/NavMenu/XDSNavHeadingMenu.tsx
index d585dba650..f64dc91ee9 100644
--- a/packages/core/src/NavMenu/XDSNavHeadingMenu.tsx
+++ b/packages/core/src/NavMenu/XDSNavHeadingMenu.tsx
@@ -5,9 +5,10 @@
import React, {useMemo, type ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import {spacingVars} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
import {useListFocus} from '../hooks/useListFocus';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
import {
XDSNavHeadingMenuContext,
useXDSNavHeadingCloseContext,
@@ -109,7 +110,7 @@ export function XDSNavHeadingMenu({
onKeyDown={handleKeyDown}
data-testid={testId}
{...mergeProps(
- xdsClassName('nav-heading-menu', {size}),
+ xdsThemeProps('nav-heading-menu', {size}),
stylex.props(styles.root, sizeStyles[size], xstyle),
className,
inlineStyle,
diff --git a/packages/core/src/NavMenu/XDSNavHeadingMenuItem.tsx b/packages/core/src/NavMenu/XDSNavHeadingMenuItem.tsx
index 31f8280d91..f46873be05 100644
--- a/packages/core/src/NavMenu/XDSNavHeadingMenuItem.tsx
+++ b/packages/core/src/NavMenu/XDSNavHeadingMenuItem.tsx
@@ -13,10 +13,11 @@ import {
typeScaleVars,
radiusVars,
} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
import {useXDSNavHeadingMenuContext} from './XDSNavMenuContext';
import {useXDSLinkComponent} from '../Link/useXDSLinkComponent';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const styles = stylex.create({
root: {
@@ -138,7 +139,7 @@ export function XDSNavHeadingMenuItem({
onClick={handleClick}
data-testid={testId}
{...mergeProps(
- xdsClassName('nav-heading-menu-item', {size}),
+ xdsThemeProps('nav-heading-menu-item', {size}),
stylex.props(
styles.root,
sizeStyles[size],
diff --git a/packages/core/src/NumberInput/XDSNumberInput.tsx b/packages/core/src/NumberInput/XDSNumberInput.tsx
index d920218eab..fd5bcf804f 100644
--- a/packages/core/src/NumberInput/XDSNumberInput.tsx
+++ b/packages/core/src/NumberInput/XDSNumberInput.tsx
@@ -128,8 +128,9 @@ export type {
XDSInputStatus as XDSNumberInputStatus,
XDSInputStatusType as XDSNumberInputStatusType,
} from '../Field';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
interface XDSNumberInputPropsBase extends Omit<
XDSBaseProps,
@@ -517,7 +518,7 @@ export function XDSNumberInput({
onClick={handleWrapperClick}
onMouseUp={handleWrapperMouseUp}
{...mergeProps(
- xdsClassName('number-input', {size, status: status?.type ?? null}),
+ xdsThemeProps('number-input', {size, status: status?.type ?? null}),
stylex.props(
inputWrapperStyles.base,
styles.wrapper,
diff --git a/packages/core/src/Outline/XDSOutline.tsx b/packages/core/src/Outline/XDSOutline.tsx
index 5e5d78c47a..7225ea81c0 100644
--- a/packages/core/src/Outline/XDSOutline.tsx
+++ b/packages/core/src/Outline/XDSOutline.tsx
@@ -26,10 +26,11 @@ import {
fontWeightVars,
} from '../theme/tokens.stylex';
import {useXDSLinkComponent} from '../Link/useXDSLinkComponent';
-import {mergeProps, mergeRefs, xdsClassName} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
import {useScrollSpy} from './useScrollSpy';
import type {OutlineItem} from './types';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
export type {OutlineItem} from './types';
@@ -187,7 +188,7 @@ export function XDSOutline({
aria-label={label}
data-testid={testId}
{...mergeProps(
- xdsClassName('outline'),
+ xdsThemeProps('outline'),
stylex.props(styles.root, xstyle),
className,
style,
@@ -202,7 +203,7 @@ export function XDSOutline({
aria-current={isActive ? 'true' : undefined}
onClick={handleClick(item.id)}
{...mergeProps(
- xdsClassName('outline-item', {
+ xdsThemeProps('outline-item', {
active: isActive ? 'active' : null,
level: item.level,
}),
diff --git a/packages/core/src/OverflowList/XDSOverflowList.tsx b/packages/core/src/OverflowList/XDSOverflowList.tsx
index 29d80ca5e3..e7699c952e 100644
--- a/packages/core/src/OverflowList/XDSOverflowList.tsx
+++ b/packages/core/src/OverflowList/XDSOverflowList.tsx
@@ -21,9 +21,10 @@ import {type ReactNode, type ReactElement, Children} from 'react';
import type {XDSBaseProps} from '../XDSBaseProps';
import type {SpacingStep} from '../utils/types';
import * as stylex from '@stylexjs/stylex';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import {useOverflow} from '../hooks/useOverflow';
import {spacingVars} from '../theme/tokens.stylex';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const styles = stylex.create({
container: {
@@ -245,7 +246,7 @@ export function XDSOverflowList({
<div
ref={mergeRefs(ref, containerRef)}
{...mergeProps(
- xdsClassName('overflow-list'),
+ xdsThemeProps('overflow-list'),
stylex.props(
styles.container,
gapStyles[gap],
diff --git a/packages/core/src/Overlay/OverlayScrim.tsx b/packages/core/src/Overlay/OverlayScrim.tsx
index 03c7f2458b..b3026dbc23 100644
--- a/packages/core/src/Overlay/OverlayScrim.tsx
+++ b/packages/core/src/Overlay/OverlayScrim.tsx
@@ -21,8 +21,9 @@ import {
spacingVars,
} from '../theme/tokens.stylex';
import {XDSMediaTheme} from '../theme/XDSMediaTheme';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {overlayScope} from './overlay.markers.stylex';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Types (re-exported from index.ts for consumers)
@@ -275,7 +276,7 @@ export function OverlayScrim({
return (
<div
{...mergeProps(
- xdsClassName('overlay-scrim', {position}),
+ xdsThemeProps('overlay-scrim', {position}),
stylex.props(
styles.base,
positionMap[position],
diff --git a/packages/core/src/Overlay/XDSOverlay.tsx b/packages/core/src/Overlay/XDSOverlay.tsx
index d70e14693d..707eebbd9e 100644
--- a/packages/core/src/Overlay/XDSOverlay.tsx
+++ b/packages/core/src/Overlay/XDSOverlay.tsx
@@ -18,10 +18,11 @@
import type {ReactNode, Ref} from 'react';
import * as stylex from '@stylexjs/stylex';
import type {StyleXStyles} from '@stylexjs/stylex';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import {useXDSOverlay} from './useXDSOverlay';
import {useIsomorphicLayoutEffect} from '../hooks/useIsomorphicLayoutEffect';
import {overlayScope, overlayContainerStyles} from './overlay.markers.stylex';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
import type {
OverlayScrimMode,
OverlayPosition,
@@ -126,7 +127,7 @@ export function XDSOverlay({
<div
ref={mergeRefs(ref, overlay.containerRef)}
{...mergeProps(
- xdsClassName('overlay'),
+ xdsThemeProps('overlay'),
stylex.props(overlayScope, overlayContainerStyles.root, xstyle),
className,
style,
diff --git a/packages/core/src/Pagination/XDSPagination.tsx b/packages/core/src/Pagination/XDSPagination.tsx
index 7daf5823d7..1f25642ded 100644
--- a/packages/core/src/Pagination/XDSPagination.tsx
+++ b/packages/core/src/Pagination/XDSPagination.tsx
@@ -34,8 +34,9 @@ import {XDSButton} from '../Button';
import {XDSIcon} from '../Icon';
import {XDSSelector} from '../Selector';
import {XDSText} from '../Text';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Types
@@ -506,7 +507,7 @@ export function XDSPagination({
onClick={() => handlePageChange(i + 1)}
disabled={isDisabled}
{...mergeProps(
- xdsClassName('pagination-dot', {
+ xdsThemeProps('pagination-dot', {
active: i + 1 === page ? 'active' : null,
size,
}),
@@ -535,7 +536,7 @@ export function XDSPagination({
aria-label={label}
data-testid={testId}
{...mergeProps(
- xdsClassName('pagination', {variant, size}),
+ xdsThemeProps('pagination', {variant, size}),
stylex.props(styles.root, xstyle),
className,
style,
diff --git a/packages/core/src/Popover/XDSPopover.tsx b/packages/core/src/Popover/XDSPopover.tsx
index 2c22f55487..c80384f977 100644
--- a/packages/core/src/Popover/XDSPopover.tsx
+++ b/packages/core/src/Popover/XDSPopover.tsx
@@ -25,13 +25,14 @@ import React, {
} from 'react';
import {useIsomorphicLayoutEffect} from '../hooks/useIsomorphicLayoutEffect';
import * as stylex from '@stylexjs/stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
import {useXDSPopover} from './useXDSPopover';
import type {LayerAlignment, LayerPlacement} from '../Layer/useXDSLayer';
import {layerAnimations} from '../Layer/layerAnimations.stylex';
import {spacingVars} from '../theme/tokens.stylex';
import {XDSInteractiveRoleContext} from '../InteractiveRoleContext/XDSInteractiveRoleContext';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Helpers
@@ -471,7 +472,7 @@ export function XDSPopover({
<div
data-testid={testId}
{...mergeProps(
- xdsClassName('popover'),
+ xdsThemeProps('popover'),
stylex.props(styles.contentPadding, xstyle),
className,
style,
@@ -507,7 +508,7 @@ export function XDSPopover({
<div
data-testid={testId}
{...mergeProps(
- xdsClassName('popover'),
+ xdsThemeProps('popover'),
stylex.props(styles.contentPadding, xstyle),
className,
style,
@@ -536,7 +537,7 @@ export function XDSPopover({
<div
data-testid={testId}
{...mergeProps(
- xdsClassName('popover'),
+ xdsThemeProps('popover'),
stylex.props(styles.contentPadding, xstyle),
className,
style,
diff --git a/packages/core/src/PowerSearch/XDSPowerSearch.tsx b/packages/core/src/PowerSearch/XDSPowerSearch.tsx
index 79bcb86d9f..05ac9bb791 100644
--- a/packages/core/src/PowerSearch/XDSPowerSearch.tsx
+++ b/packages/core/src/PowerSearch/XDSPowerSearch.tsx
@@ -44,12 +44,13 @@ import {
typeScaleVars,
fontWeightVars,
} from '../theme/tokens.stylex';
-import {xdsClassName, mergeRefs} from '../utils';
+import {mergeRefs} from '../utils';
import {useXDSSize} from '../SizeContext/XDSSizeContext';
import {useInternalConfig} from './useInternalConfig';
import {usePowerSearchSource} from './usePowerSearchSource';
import {formatFilterValue} from './formatFilterValue';
import {PowerSearchEditPopover} from './PowerSearchEditPopover';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
import type {
PowerSearchConfig,
PowerSearchFilter,
@@ -965,7 +966,7 @@ export function XDSPowerSearch({
<>
<div
ref={mergeRefs(ref, popover.triggerRef as React.Ref<HTMLDivElement>)}
- className={xdsClassName('power-search')}>
+ {...xdsThemeProps('power-search')}>
<XDSTokenizer
handleRef={tokenizerRef}
label={label}
diff --git a/packages/core/src/ProgressBar/XDSProgressBar.tsx b/packages/core/src/ProgressBar/XDSProgressBar.tsx
index 239b2bf60a..79d09853cd 100644
--- a/packages/core/src/ProgressBar/XDSProgressBar.tsx
+++ b/packages/core/src/ProgressBar/XDSProgressBar.tsx
@@ -28,8 +28,9 @@ import {
easeVars,
typeScaleVars,
} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
/**
* Extensible variant map for XDSProgressBar.
@@ -282,7 +283,7 @@ export function XDSProgressBar({
<div
ref={ref}
{...mergeProps(
- xdsClassName('progressbar', {variant}),
+ xdsThemeProps('progressbar', {variant}),
stylex.props(styles.container, xstyle),
className,
style,
@@ -326,13 +327,13 @@ export function XDSProgressBar({
aria-labelledby={labelId}
aria-valuetext={isIndeterminate ? undefined : valueText}
{...mergeProps(
- xdsClassName('progressbar-track'),
+ xdsThemeProps('progressbar-track'),
stylex.props(styles.track),
)}>
{isIndeterminate ? (
<div
{...mergeProps(
- xdsClassName('progressbar-fill', {variant: fillVariant}),
+ xdsThemeProps('progressbar-fill', {variant: fillVariant}),
stylex.props(
styles.indeterminateFill,
variantStyles[fillVariant],
@@ -342,7 +343,7 @@ export function XDSProgressBar({
) : (
<div
{...mergeProps(
- xdsClassName('progressbar-fill', {variant: fillVariant}),
+ xdsThemeProps('progressbar-fill', {variant: fillVariant}),
stylex.props(styles.fill, variantStyles[fillVariant]),
)}
style={{width: `${percentage}%`}}
diff --git a/packages/core/src/RadioList/XDSRadioList.tsx b/packages/core/src/RadioList/XDSRadioList.tsx
index 26d746de26..0f7bc80735 100644
--- a/packages/core/src/RadioList/XDSRadioList.tsx
+++ b/packages/core/src/RadioList/XDSRadioList.tsx
@@ -21,8 +21,9 @@ import * as stylex from '@stylexjs/stylex';
import {spacingVars} from '../theme/tokens.stylex';
import {XDSField} from '../Field/XDSField';
import type {XDSInputStatus} from '../Field/types';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
/**
* Size of the radio controls, matching CheckboxInput sizes.
@@ -214,7 +215,7 @@ export function XDSRadioList({
aria-invalid={status?.type === 'error' ? true : undefined}
aria-required={isRequired || undefined}
{...mergeProps(
- xdsClassName('radio-list', {orientation, size}),
+ xdsThemeProps('radio-list', {orientation, size}),
stylex.props(
styles.radiogroup,
orientation === 'vertical' ? styles.vertical : styles.horizontal,
diff --git a/packages/core/src/RadioList/XDSRadioListItem.tsx b/packages/core/src/RadioList/XDSRadioListItem.tsx
index 05eee26852..f824f81dd2 100644
--- a/packages/core/src/RadioList/XDSRadioListItem.tsx
+++ b/packages/core/src/RadioList/XDSRadioListItem.tsx
@@ -29,9 +29,10 @@ import {
borderVars,
} from '../theme/tokens.stylex';
import {XDSRadioListContext} from './XDSRadioList';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {radioScope} from './radio.markers.stylex';
import {XDSItem} from '../Item';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const styles = stylex.create({
container: {
@@ -258,7 +259,7 @@ export function XDSRadioListItem({
<div
aria-hidden="true"
{...mergeProps(
- xdsClassName('radio', {
+ xdsThemeProps('radio', {
size,
checked: isChecked ? 'checked' : null,
disabled: isDisabled ? 'disabled' : null,
@@ -274,7 +275,7 @@ export function XDSRadioListItem({
{isChecked && (
<div
{...mergeProps(
- xdsClassName('radio-dot', {size}),
+ xdsThemeProps('radio-dot', {size}),
stylex.props(styles.innerDot, dotSizeStyles[size]),
)}
/>
@@ -298,7 +299,7 @@ export function XDSRadioListItem({
ref={ref}
data-testid={dataTestId}
{...mergeProps(
- xdsClassName('radio-list-item'),
+ xdsThemeProps('radio-list-item'),
stylex.props(styles.container, !isDisabled && radioScope),
)}>
<XDSItem
diff --git a/packages/core/src/Resizable/XDSResizeHandle.tsx b/packages/core/src/Resizable/XDSResizeHandle.tsx
index eeccd7033c..6486c996b8 100644
--- a/packages/core/src/Resizable/XDSResizeHandle.tsx
+++ b/packages/core/src/Resizable/XDSResizeHandle.tsx
@@ -15,7 +15,7 @@
* flips when the panel collapses to 0px so it stays accessible.
*
* Pill placement uses a single stylex dynamic style that accepts a direction
- * multiplier (-1 or 1). The pill element has its own xdsClassName
+ * multiplier (-1 or 1). The pill element has its own xdsThemeProps
* ('resize-handle-pill') so themes can target size/shape directly.
*/
@@ -30,8 +30,9 @@ import {
radiusVars,
spacingVars,
} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import type {ResizableProps} from './useXDSResizable';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const KEYBOARD_STEP = 10;
const KEYBOARD_LARGE_STEP = 50;
@@ -485,7 +486,7 @@ export function XDSResizeHandle({
onBlur={() => setIsFocused(false)}
data-resizing={isDragging || undefined}
{...mergeProps(
- xdsClassName('resize-handle'),
+ xdsThemeProps('resize-handle'),
stylex.props(
styles.handle,
isOverlay && styles.overlay,
@@ -531,7 +532,7 @@ export function XDSResizeHandle({
{children ?? (
<div
{...mergeProps(
- xdsClassName('resize-handle-pill'),
+ xdsThemeProps('resize-handle-pill'),
stylex.props(
styles.pill,
isHorizontal ? styles.pillHorizontal : styles.pillVertical,
diff --git a/packages/core/src/Section/XDSSection.tsx b/packages/core/src/Section/XDSSection.tsx
index 4a86b5bc6d..ba9cfd99e4 100644
--- a/packages/core/src/Section/XDSSection.tsx
+++ b/packages/core/src/Section/XDSSection.tsx
@@ -31,7 +31,8 @@ import {
spacingStepToToken,
} from '../Layout/padding.stylex';
import type {SizeValue, SpacingStep} from '../utils/types';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
/**
* Extensible variant map for XDSSection.
@@ -267,7 +268,7 @@ export function XDSSection({
{...props}>
<div
{...mergeProps(
- xdsClassName('section', {variant}),
+ xdsThemeProps('section', {variant}),
stylex.props(
nestedStyles.inner,
...container(
diff --git a/packages/core/src/SegmentedControl/XDSSegmentedControl.tsx b/packages/core/src/SegmentedControl/XDSSegmentedControl.tsx
index 17a75a10db..b28cde7858 100644
--- a/packages/core/src/SegmentedControl/XDSSegmentedControl.tsx
+++ b/packages/core/src/SegmentedControl/XDSSegmentedControl.tsx
@@ -23,9 +23,10 @@ import type {
XDSSegmentedControlSize,
XDSSegmentedControlLayout,
} from './XDSSegmentedControlContext';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import {useXDSSize} from '../SizeContext/XDSSizeContext';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
export interface XDSSegmentedControlProps extends Omit<
XDSBaseProps<HTMLDivElement>,
@@ -205,7 +206,7 @@ export function XDSSegmentedControl({
aria-disabled={isDisabled || undefined}
onKeyDown={handleKeyDown}
{...mergeProps(
- xdsClassName('segmented-control', {size}),
+ xdsThemeProps('segmented-control', {size}),
stylex.props(
styles.container,
sizeStyles[size],
diff --git a/packages/core/src/SegmentedControl/XDSSegmentedControlItem.tsx b/packages/core/src/SegmentedControl/XDSSegmentedControlItem.tsx
index efbce3ca67..6577bcee66 100644
--- a/packages/core/src/SegmentedControl/XDSSegmentedControlItem.tsx
+++ b/packages/core/src/SegmentedControl/XDSSegmentedControlItem.tsx
@@ -29,8 +29,9 @@ import {
} from '../theme/tokens.stylex';
import {useXDSSegmentedControlContext} from './XDSSegmentedControlContext';
import type {XDSSegmentedControlSize} from './XDSSegmentedControlContext';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
export interface XDSSegmentedControlItemProps extends XDSBaseProps<HTMLButtonElement> {
ref?: React.Ref<HTMLButtonElement>;
@@ -197,7 +198,7 @@ export function XDSSegmentedControlItem({
tabIndex={isSelected ? 0 : -1}
onClick={handleClick}
{...mergeProps(
- xdsClassName('segmented-control-item', {
+ xdsThemeProps('segmented-control-item', {
size,
selected: isSelected ? 'selected' : null,
disabled: isItemDisabled ? 'disabled' : null,
diff --git a/packages/core/src/SelectableCard/XDSSelectableCard.tsx b/packages/core/src/SelectableCard/XDSSelectableCard.tsx
index 625d7d0255..3c1dea5ad1 100644
--- a/packages/core/src/SelectableCard/XDSSelectableCard.tsx
+++ b/packages/core/src/SelectableCard/XDSSelectableCard.tsx
@@ -37,11 +37,12 @@ import * as stylex from '@stylexjs/stylex';
import type {StyleXStyles} from '@stylexjs/stylex';
import {colorVars} from '../theme/tokens.stylex';
import type {SizeValue, SpacingStep} from '../utils/types';
-import {xdsClassName, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import {XDSCard} from '../Card/XDSCard';
import type {XDSCardVariant} from '../Card/XDSCard';
import {useClickableContainer} from '../hooks/useClickableContainer';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Styles — selection + interaction; Card handles the rest
@@ -323,17 +324,13 @@ export function XDSSelectableCard({
maxWidth={maxWidth}
padding={padding}
variant={variant}
- className={
- classNameProp
- ? `${xdsClassName('selectable-card', {
- variant,
- selected: isSelected ? 'true' : 'false',
- })} ${classNameProp}`
- : xdsClassName('selectable-card', {
- variant,
- selected: isSelected ? 'true' : 'false',
- })
- }
+ {...mergeProps(
+ xdsThemeProps('selectable-card', {
+ variant,
+ selected: isSelected ? 'true' : 'false',
+ }),
+ {className: classNameProp, style},
+ )}
xstyle={
[
styles.interactive,
@@ -345,7 +342,6 @@ export function XDSSelectableCard({
xstyleProp,
] as unknown as StyleXStyles
}
- style={style}
onClick={!isDisabled ? composedOnClick : undefined}
onMouseUp={!isDisabled ? composedOnMouseUp : undefined}
{...props}>
diff --git a/packages/core/src/Selector/XDSSelector.tsx b/packages/core/src/Selector/XDSSelector.tsx
index 3444f42a29..ea491a5031 100644
--- a/packages/core/src/Selector/XDSSelector.tsx
+++ b/packages/core/src/Selector/XDSSelector.tsx
@@ -61,9 +61,10 @@ import {
} from './utils';
import {useCombobox, useSelectedItemOffset} from './hooks';
import {XDSSelectorOption} from './XDSSelectorOption';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {useXDSSize} from '../SizeContext/XDSSizeContext';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const styles = stylex.create({
// Trigger container — the enhanced click target wrapping the combobox button and clear button as siblings
@@ -859,7 +860,7 @@ export function XDSSelector<T extends XDSSelectorOptionType>(
onClick={onTriggerClick}
data-testid={testId}
{...mergeProps(
- xdsClassName('selector', {size, status: status?.type ?? null}),
+ xdsThemeProps('selector', {size, status: status?.type ?? null}),
stylex.props(
inputWrapperStyles.base,
styles.triggerContainer,
diff --git a/packages/core/src/Selector/XDSSelectorOption.tsx b/packages/core/src/Selector/XDSSelectorOption.tsx
index 2610caa6af..b6b81b57c9 100644
--- a/packages/core/src/Selector/XDSSelectorOption.tsx
+++ b/packages/core/src/Selector/XDSSelectorOption.tsx
@@ -13,7 +13,8 @@ import * as stylex from '@stylexjs/stylex';
import type {StyleXStyles} from '@stylexjs/stylex';
import {renderIconSlot, type XDSIconType} from '../Icon';
import {XDSItem} from '../Item';
-import {xdsClassName} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const embeddedStyles = stylex.create({
root: {
@@ -110,10 +111,7 @@ export function XDSSelectorOption({
description={description}
endContent={children}
xstyle={[embeddedStyles.root, xstyle]}
- className={[xdsClassName('selector-option'), className]
- .filter(Boolean)
- .join(' ')}
- style={style}
+ {...mergeProps(xdsThemeProps('selector-option'), {className, style})}
/>
);
}
diff --git a/packages/core/src/SideNav/XDSSideNav.tsx b/packages/core/src/SideNav/XDSSideNav.tsx
index cfb7d82278..3f5ef1c664 100644
--- a/packages/core/src/SideNav/XDSSideNav.tsx
+++ b/packages/core/src/SideNav/XDSSideNav.tsx
@@ -32,7 +32,7 @@ import type {XDSBaseProps} from '../XDSBaseProps';
import * as stylex from '@stylexjs/stylex';
import type {StyleXStyles} from '@stylexjs/stylex';
import {borderVars, colorVars, spacingVars} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import {
XDSSideNavCollapseContext,
type XDSSideNavCollapseState,
@@ -44,6 +44,7 @@ import {XDSMobileNav} from '../MobileNav/XDSMobileNav';
import {useXDSResizable} from '../Resizable/useXDSResizable';
import type {XDSResizableConfig} from '../Resizable/useXDSResizable';
import {XDSResizeHandle} from '../Resizable/XDSResizeHandle';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Constants
@@ -426,7 +427,7 @@ export function XDSSideNav({
<div
data-testid={testId}
{...mergeProps(
- xdsClassName('side-nav', {mode: 'topbar'}),
+ xdsThemeProps('side-nav', {mode: 'topbar'}),
stylex.props(styles.topbar, xstyle),
className,
style,
@@ -502,7 +503,7 @@ export function XDSSideNav({
aria-label="Side navigation"
data-testid={testId}
{...mergeProps(
- xdsClassName('side-nav'),
+ xdsThemeProps('side-nav'),
stylex.props(styles.root, collapsed && styles.rootCollapsed, xstyle),
className,
resizableNavStyle,
diff --git a/packages/core/src/SideNav/XDSSideNavHeading.tsx b/packages/core/src/SideNav/XDSSideNavHeading.tsx
index 771137d937..982a883537 100644
--- a/packages/core/src/SideNav/XDSSideNavHeading.tsx
+++ b/packages/core/src/SideNav/XDSSideNavHeading.tsx
@@ -39,10 +39,11 @@ import {navItemStyles} from '../NavItem/navItemStyles.stylex';
import {useXDSSideNavCollapse} from './XDSSideNavCollapseContext';
import {useXDSLinkComponent} from '../Link/useXDSLinkComponent';
import type {XDSLinkComponentType} from '../Link/types';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
import {useXDSMenuHover} from '../hooks/useXDSMenuHover';
import {XDSNavHeadingCloseContext} from '../NavMenu/XDSNavMenuContext';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Styles
@@ -391,7 +392,7 @@ export function XDSSideNavHeading({
aria-label={heading}
data-testid={testId}
{...mergeProps(
- xdsClassName('side-nav-heading'),
+ xdsThemeProps('side-nav-heading'),
stylex.props(navItemStyles.item, styles.rootCollapsed, xstyle),
className,
style,
@@ -410,7 +411,7 @@ export function XDSSideNavHeading({
{...popover.triggerProps}
{...triggerProps}
{...mergeProps(
- xdsClassName('side-nav-heading'),
+ xdsThemeProps('side-nav-heading'),
stylex.props(
navItemStyles.item,
styles.rootCollapsed,
@@ -472,7 +473,7 @@ export function XDSSideNavHeading({
ref={collapsedSetRef}
data-testid={testId}
{...mergeProps(
- xdsClassName('side-nav-heading'),
+ xdsThemeProps('side-nav-heading'),
stylex.props(styles.root, styles.rootCollapsed, xstyle),
className,
style,
@@ -570,7 +571,7 @@ export function XDSSideNavHeading({
href={headingHref}
data-testid={testId}
{...mergeProps(
- xdsClassName('side-nav-heading'),
+ xdsThemeProps('side-nav-heading'),
stylex.props(styles.root, styles.menuTrigger, xstyle),
className,
style,
@@ -593,7 +594,7 @@ export function XDSSideNavHeading({
data-testid={testId}
{...triggerProps}
{...mergeProps(
- xdsClassName('side-nav-heading'),
+ xdsThemeProps('side-nav-heading'),
stylex.props(styles.root, styles.menuTrigger, xstyle),
className,
style,
@@ -644,7 +645,7 @@ export function XDSSideNavHeading({
data-testid={testId}
{...triggerProps}
{...mergeProps(
- xdsClassName('side-nav-heading'),
+ xdsThemeProps('side-nav-heading'),
stylex.props(styles.root, xstyle),
className,
style,
@@ -700,7 +701,7 @@ export function XDSSideNavHeading({
ref={ref}
data-testid={testId}
{...mergeProps(
- xdsClassName('side-nav-heading'),
+ xdsThemeProps('side-nav-heading'),
stylex.props(styles.root, xstyle),
className,
style,
@@ -757,7 +758,7 @@ export function XDSSideNavHeading({
ref={ref}
data-testid={testId}
{...mergeProps(
- xdsClassName('side-nav-heading'),
+ xdsThemeProps('side-nav-heading'),
stylex.props(styles.root, xstyle),
className,
style,
diff --git a/packages/core/src/SideNav/XDSSideNavItem.tsx b/packages/core/src/SideNav/XDSSideNavItem.tsx
index d489ce9108..6ebcdce371 100644
--- a/packages/core/src/SideNav/XDSSideNavItem.tsx
+++ b/packages/core/src/SideNav/XDSSideNavItem.tsx
@@ -42,7 +42,7 @@ import {renderIconSlot, type XDSIconType} from '../Icon';
import {useXDSLinkComponent} from '../Link/useXDSLinkComponent';
import type {XDSLinkComponentType} from '../Link/types';
import {useXDSPopover} from '../Popover/useXDSPopover';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
import {XDSTooltip} from '../Tooltip';
import {navItemStyles, type NavItemSize} from '../NavItem/navItemStyles.stylex';
@@ -53,6 +53,7 @@ import {
import {getIcon} from '../Icon/globalIconRegistry';
import {useXDSSideNavRenderMode} from './XDSSideNavRenderContext';
import {useXDSAppShellMobile} from '../AppShell/XDSAppShellMobileContext';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Styles
@@ -481,7 +482,7 @@ export function XDSSideNavItem({
// Shared collapsed item styles — used by trigger, link, and button
const collapsedItemStyles = mergeProps(
- xdsClassName('side-nav-item', {
+ xdsThemeProps('side-nav-item', {
size,
selected: isSelected ? 'selected' : null,
}),
@@ -582,7 +583,7 @@ export function XDSSideNavItem({
);
const navItemStyleProps = mergeProps(
- xdsClassName('side-nav-item', {
+ xdsThemeProps('side-nav-item', {
size,
selected: isSelected ? 'selected' : null,
}),
diff --git a/packages/core/src/SideNav/XDSSideNavSection.tsx b/packages/core/src/SideNav/XDSSideNavSection.tsx
index 7887c72b9c..a52dd91c93 100644
--- a/packages/core/src/SideNav/XDSSideNavSection.tsx
+++ b/packages/core/src/SideNav/XDSSideNavSection.tsx
@@ -26,9 +26,10 @@ import {
fontWeightVars,
typeScaleVars,
} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
import {useXDSSideNavCollapse} from './XDSSideNavCollapseContext';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Styles
// =============================================================================
@@ -186,7 +187,7 @@ export function XDSSideNavSection({
aria-labelledby={titleId}
data-testid={testId}
{...mergeProps(
- xdsClassName('side-nav-section'),
+ xdsThemeProps('side-nav-section'),
stylex.props(styles.root, xstyle),
className,
style,
diff --git a/packages/core/src/Skeleton/XDSSkeleton.tsx b/packages/core/src/Skeleton/XDSSkeleton.tsx
index 93826e11de..228a083666 100644
--- a/packages/core/src/Skeleton/XDSSkeleton.tsx
+++ b/packages/core/src/Skeleton/XDSSkeleton.tsx
@@ -18,7 +18,8 @@
import type {XDSBaseProps} from '../XDSBaseProps';
import * as stylex from '@stylexjs/stylex';
import {colorVars, radiusVars, durationVars} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Animation Timing Constants
@@ -181,7 +182,7 @@ export function XDSSkeleton({
ref={ref}
data-testid={testId}
{...mergeProps(
- xdsClassName('skeleton'),
+ xdsThemeProps('skeleton'),
stylex.props(
styles.root,
styles.animate,
diff --git a/packages/core/src/Slider/XDSSlider.tsx b/packages/core/src/Slider/XDSSlider.tsx
index 7db6b38596..64b7157a0c 100644
--- a/packages/core/src/Slider/XDSSlider.tsx
+++ b/packages/core/src/Slider/XDSSlider.tsx
@@ -38,8 +38,9 @@ import {
import {XDSField} from '../Field/XDSField';
import {XDSTooltip} from '../Tooltip/XDSTooltip';
import type {XDSInputStatus} from '../Field/types';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Types
@@ -652,7 +653,7 @@ export function XDSSlider({ref, ...props}: XDSSliderProps) {
aria-describedby={ariaDescribedBy}
onKeyDown={e => handleKeyDown(thumbIndex, e)}
{...mergeProps(
- xdsClassName('slider-thumb', {
+ xdsThemeProps('slider-thumb', {
orientation,
disabled: isDisabled ? 'disabled' : null,
}),
@@ -741,7 +742,7 @@ export function XDSSlider({ref, ...props}: XDSSliderProps) {
style={style}>
<div
{...mergeProps(
- xdsClassName('slider', {
+ xdsThemeProps('slider', {
orientation,
disabled: isDisabled ? 'disabled' : null,
}),
@@ -765,7 +766,7 @@ export function XDSSlider({ref, ...props}: XDSSliderProps) {
<div
aria-hidden="true"
{...mergeProps(
- xdsClassName('slider-track', {orientation}),
+ xdsThemeProps('slider-track', {orientation}),
stylex.props(
styles.track,
isHorizontal ? styles.trackHorizontal : styles.trackVertical,
diff --git a/packages/core/src/Spinner/XDSSpinner.tsx b/packages/core/src/Spinner/XDSSpinner.tsx
index 45612d04fb..8fca7d1923 100644
--- a/packages/core/src/Spinner/XDSSpinner.tsx
+++ b/packages/core/src/Spinner/XDSSpinner.tsx
@@ -22,7 +22,8 @@ import {durationVars, spacingVars} from '../theme/tokens.stylex';
import {useXDSTheme} from '../theme/useXDSTheme';
import type {XDSBaseProps} from '../XDSBaseProps';
import {XDSText} from '../Text/XDSText';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Constants
@@ -236,7 +237,7 @@ export function XDSSpinner({
data-testid={hasLabel ? undefined : testId}
{...(hasLabel ? {} : restProps)}
{...mergeProps(
- hasLabel ? '' : xdsClassName('spinner', {size, shade}),
+ hasLabel ? '' : xdsThemeProps('spinner', {size, shade}),
stylex.props(styles.spinner, !hasLabel && xstyle),
hasLabel ? undefined : className,
{...(hasLabel ? {} : style), width: frameSize, height: frameSize},
@@ -255,7 +256,7 @@ export function XDSSpinner({
data-testid={testId}
{...restProps}
{...mergeProps(
- xdsClassName('spinner', {size, shade}),
+ xdsThemeProps('spinner', {size, shade}),
stylex.props(styles.wrapper, xstyle),
className,
style,
diff --git a/packages/core/src/Stack/XDSStack.tsx b/packages/core/src/Stack/XDSStack.tsx
index f1e5cb6903..82f5831823 100644
--- a/packages/core/src/Stack/XDSStack.tsx
+++ b/packages/core/src/Stack/XDSStack.tsx
@@ -25,7 +25,8 @@ import {
type SpacingStep,
} from './stack.stylex';
import type {SizeValue} from '../utils/types';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
/**
* Alignment values accepted by XDSStack.
@@ -234,7 +235,7 @@ export function XDSStack({
{
ref: ref as Ref<Element>,
...mergeProps(
- xdsClassName('stack', {direction, gap, wrap}),
+ xdsThemeProps('stack', {direction, gap, wrap}),
stylexProps,
className,
{...style, ...sizingStyle},
diff --git a/packages/core/src/Stack/XDSStackItem.tsx b/packages/core/src/Stack/XDSStackItem.tsx
index 95dee5527e..022166a0fc 100644
--- a/packages/core/src/Stack/XDSStackItem.tsx
+++ b/packages/core/src/Stack/XDSStackItem.tsx
@@ -20,7 +20,8 @@ import {
type StackItemCrossAlignSelf,
type StackItemSize,
} from './stackItem.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
export interface XDSStackItemProps extends XDSBaseProps<HTMLElement> {
/** Ref forwarded to the root element */
@@ -109,7 +110,7 @@ export function XDSStackItem({
{
ref: ref as Ref<Element>,
...mergeProps(
- xdsClassName('stack-item', {size}),
+ xdsThemeProps('stack-item', {size}),
stylexProps,
className,
style,
diff --git a/packages/core/src/StatusDot/XDSStatusDot.tsx b/packages/core/src/StatusDot/XDSStatusDot.tsx
index f5d92e9b07..c61a63020f 100644
--- a/packages/core/src/StatusDot/XDSStatusDot.tsx
+++ b/packages/core/src/StatusDot/XDSStatusDot.tsx
@@ -20,7 +20,8 @@ import * as stylex from '@stylexjs/stylex';
import {colorVars} from '../theme/tokens.stylex';
import type {XDSBaseProps} from '../XDSBaseProps';
import {XDSTooltip} from '../Tooltip/XDSTooltip';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
/**
* Pulse animation keyframes
@@ -159,7 +160,7 @@ export function XDSStatusDot({
role="img"
aria-label={label}
{...mergeProps(
- xdsClassName('statusdot', {variant}),
+ xdsThemeProps('statusdot', {variant}),
stylex.props(
styles.base,
variants[variant],
diff --git a/packages/core/src/Switch/XDSSwitch.tsx b/packages/core/src/Switch/XDSSwitch.tsx
index 827e18f82f..19242dbaad 100644
--- a/packages/core/src/Switch/XDSSwitch.tsx
+++ b/packages/core/src/Switch/XDSSwitch.tsx
@@ -39,9 +39,10 @@ import {XDSFieldStatus} from '../FieldStatus/XDSFieldStatus';
import type {XDSIconType} from '../Icon';
import type {XDSInputStatus} from '../Field/types';
import {XDSSpinner} from '../Spinner';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {switchScope} from './switch.markers.stylex';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// Fixed dimensions: 40px width, 24px height, 16px thumb (off), 20px thumb (on)
const SWITCH_WIDTH = 40;
@@ -382,7 +383,7 @@ export function XDSSwitch({
<div
aria-hidden="true"
{...mergeProps(
- xdsClassName('switch', {
+ xdsThemeProps('switch', {
checked: isOn ? 'checked' : null,
disabled: isDisabled ? 'disabled' : null,
}),
@@ -396,7 +397,7 @@ export function XDSSwitch({
)}>
<div
{...mergeProps(
- xdsClassName('switch-thumb', {checked: isOn ? 'checked' : null}),
+ xdsThemeProps('switch-thumb', {checked: isOn ? 'checked' : null}),
stylex.props(styles.thumb, isOn ? styles.thumbOn : styles.thumbOff),
)}>
{isBusy && <XDSSpinner size="sm" />}
@@ -430,7 +431,7 @@ export function XDSSwitch({
return (
<div
{...mergeProps(
- xdsClassName('switch-field', {
+ xdsThemeProps('switch-field', {
labelPosition: labelPosition !== 'end' ? labelPosition : undefined,
labelSpacing: labelSpacing !== 'default' ? labelSpacing : undefined,
}),
diff --git a/packages/core/src/TabList/XDSTab.tsx b/packages/core/src/TabList/XDSTab.tsx
index 2415a5b007..61d4682382 100644
--- a/packages/core/src/TabList/XDSTab.tsx
+++ b/packages/core/src/TabList/XDSTab.tsx
@@ -34,8 +34,9 @@ import type {XDSTabListSize} from './XDSTabListContext';
import {tabScope} from './tab.markers.stylex';
import {useXDSLinkComponent} from '../Link/useXDSLinkComponent';
import type {XDSLinkComponentType} from '../Link/types';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {EDGE_COMP_ATTR} from '../Layout/edgeCompensation.stylex';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
export interface XDSTabProps extends XDSBaseProps<HTMLButtonElement> {
/**
@@ -260,7 +261,7 @@ export function XDSTab({
[EDGE_COMP_ATTR]: '',
'aria-current': isSelected ? ('page' as const) : undefined,
...mergeProps(
- xdsClassName('tab', {
+ xdsThemeProps('tab', {
selected: isSelected ? 'selected' : null,
}),
stylex.props(
@@ -286,7 +287,7 @@ export function XDSTab({
const indicatorElement = (
<span
{...mergeProps(
- xdsClassName('tab-indicator', {
+ xdsThemeProps('tab-indicator', {
selected: isSelected ? 'selected' : null,
}),
stylex.props(
diff --git a/packages/core/src/TabList/XDSTabList.tsx b/packages/core/src/TabList/XDSTabList.tsx
index 1ed4d4a11a..6ec4eda025 100644
--- a/packages/core/src/TabList/XDSTabList.tsx
+++ b/packages/core/src/TabList/XDSTabList.tsx
@@ -22,8 +22,9 @@ import type {XDSBaseProps} from '../XDSBaseProps';
import {XDSTabListContext} from './XDSTabListContext';
import type {XDSTabListSize} from './XDSTabListContext';
import {useXDSSize} from '../SizeContext/XDSSizeContext';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {EDGE_COMP_ATTR} from '../Layout/edgeCompensation.stylex';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
export interface XDSTabListProps extends Omit<
XDSBaseProps<HTMLElement>,
@@ -124,7 +125,7 @@ export function XDSTabList({
{...{[EDGE_COMP_ATTR]: ''}}
{...restProps}
{...mergeProps(
- xdsClassName('tab-list', {size}),
+ xdsThemeProps('tab-list', {size}),
stylex.props(
styles.nav,
layout === 'fill' && styles.fill,
diff --git a/packages/core/src/TabList/XDSTabMenu.tsx b/packages/core/src/TabList/XDSTabMenu.tsx
index f9b5dfa657..797467064e 100644
--- a/packages/core/src/TabList/XDSTabMenu.tsx
+++ b/packages/core/src/TabList/XDSTabMenu.tsx
@@ -35,8 +35,9 @@ import {useListFocus} from '../hooks/useListFocus';
import {useXDSTabListContext} from './XDSTabListContext';
import type {XDSTabListSize} from './XDSTabListContext';
import {tabScope} from './tab.markers.stylex';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
export interface XDSTabMenuOption {
value: string;
@@ -307,7 +308,7 @@ export function XDSTabMenu({
aria-controls={menuId}
onClick={handleToggle}
{...mergeProps(
- xdsClassName('tab-menu'),
+ xdsThemeProps('tab-menu'),
stylex.props(
styles.trigger,
sizeStyles[size],
@@ -339,7 +340,7 @@ export function XDSTabMenu({
{hasSelectedOption && (
<span
{...mergeProps(
- xdsClassName('tab-indicator', {selected: 'selected'}),
+ xdsThemeProps('tab-indicator', {selected: 'selected'}),
stylex.props(styles.indicator, styles.indicatorSelected),
)}
/>
@@ -353,7 +354,7 @@ export function XDSTabMenu({
aria-label={label}
onKeyDown={handleListKeyDown}
{...mergeProps(
- xdsClassName('tab-menu-dropdown'),
+ xdsThemeProps('tab-menu-dropdown'),
stylex.props(styles.dropdown),
)}>
<span role="presentation" {...stylex.props(styles.menuHeading)}>
@@ -375,7 +376,7 @@ export function XDSTabMenu({
}
}}
{...mergeProps(
- xdsClassName('tab-menu-item'),
+ xdsThemeProps('tab-menu-item'),
stylex.props(
styles.menuItem,
isSelected && styles.menuItemSelected,
diff --git a/packages/core/src/Table/XDSBaseTable.tsx b/packages/core/src/Table/XDSBaseTable.tsx
index a4c19e61a5..367c604ded 100644
--- a/packages/core/src/Table/XDSBaseTable.tsx
+++ b/packages/core/src/Table/XDSBaseTable.tsx
@@ -40,9 +40,10 @@ import {XDSTableCell} from './XDSTableCell';
import {XDSTableHeaderCell} from './XDSTableHeaderCell';
import {XDSTableHeader} from './XDSTableHeader';
import {XDSTableBody} from './XDSTableBody';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {XDSEmptyState} from '../EmptyState';
import {XDSText} from '../Text';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const styles = stylex.create({
table: {
@@ -451,11 +452,9 @@ function XDSBaseTableInner<T extends Record<string, unknown>>({
ref={ref}
{...tableRenderProps.htmlProps}
{...mergeProps(
- xdsClassName('base-table') +
- (tableRenderProps.htmlProps.className
- ? ` ${tableRenderProps.htmlProps.className}`
- : ''),
+ xdsThemeProps('base-table'),
stylex.props(...tableRenderProps.styles),
+ tableRenderProps.htmlProps.className,
)}
style={tableStyle}>
{children ? (
diff --git a/packages/core/src/Table/XDSTable.tsx b/packages/core/src/Table/XDSTable.tsx
index 56c315e877..009b9bc9c3 100644
--- a/packages/core/src/Table/XDSTable.tsx
+++ b/packages/core/src/Table/XDSTable.tsx
@@ -22,7 +22,8 @@ import {colorVars} from '../theme/tokens.stylex';
import {XDSBaseTable} from './XDSBaseTable';
import {XDSTableContext} from './XDSTableContext';
import {useXDSBaseTablePlugins} from './useXDSBaseTablePlugins';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
import type {
XDSBaseTableProps,
XDSTableVerticalAlign,
@@ -134,7 +135,7 @@ function TableScrollWrapper({children}: {children: React.ReactNode}) {
return (
<div
{...mergeProps(
- xdsClassName('table-scroll-wrapper'),
+ xdsThemeProps('table-scroll-wrapper'),
stylex.props(
scrollWrapperStyles.base,
scrollWrapperStyles.containerBleed,
@@ -155,7 +156,7 @@ function buildTableStylePlugin<
return {
transformTable(props: TableRenderProps): TableRenderProps {
const existingClass = props.htmlProps.className ?? '';
- const tableClass = xdsClassName('table');
+ const tableClass = xdsThemeProps('table').className;
return {
...props,
htmlProps: {
diff --git a/packages/core/src/Table/XDSTableBody.tsx b/packages/core/src/Table/XDSTableBody.tsx
index b31758ad63..a7ab72b00e 100644
--- a/packages/core/src/Table/XDSTableBody.tsx
+++ b/packages/core/src/Table/XDSTableBody.tsx
@@ -5,7 +5,8 @@ import type React from 'react';
import type {ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import type {XDSBaseProps} from '../XDSBaseProps';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
export interface XDSTableBodyProps extends XDSBaseProps<HTMLTableSectionElement> {
ref?: React.Ref<HTMLTableSectionElement>;
@@ -16,7 +17,7 @@ export function XDSTableBody({ref, children, xstyle}: XDSTableBodyProps) {
return (
<tbody
ref={ref}
- {...mergeProps(xdsClassName('table-body'), stylex.props(xstyle))}>
+ {...mergeProps(xdsThemeProps('table-body'), stylex.props(xstyle))}>
{children}
</tbody>
);
diff --git a/packages/core/src/Table/XDSTableCell.tsx b/packages/core/src/Table/XDSTableCell.tsx
index 95ef459492..14dfffe15b 100644
--- a/packages/core/src/Table/XDSTableCell.tsx
+++ b/packages/core/src/Table/XDSTableCell.tsx
@@ -35,7 +35,8 @@ import {
buildDividerStyles,
mergeXStyle,
} from './useTableCellStyles';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
/** Props for XDSTableCell — thin `<td>` wrapper */
export interface XDSTableCellProps extends XDSBaseProps<HTMLTableCellElement> {
@@ -147,7 +148,7 @@ export function XDSTableCell({
ref={ref}
{...props}
{...mergeProps(
- xdsClassName('table-cell'),
+ xdsThemeProps('table-cell'),
stylex.props(xstyle),
incomingClassName,
incomingStyle,
@@ -170,7 +171,7 @@ export function XDSTableCell({
ref={ref}
{...props}
{...mergeProps(
- xdsClassName('table-cell'),
+ xdsThemeProps('table-cell'),
stylex.props(...mergeXStyle(cellStyles, xstyle)),
incomingClassName,
incomingStyle,
diff --git a/packages/core/src/Table/XDSTableFooter.tsx b/packages/core/src/Table/XDSTableFooter.tsx
index 6057b7ae15..52749e8d0d 100644
--- a/packages/core/src/Table/XDSTableFooter.tsx
+++ b/packages/core/src/Table/XDSTableFooter.tsx
@@ -5,7 +5,8 @@ import type React from 'react';
import type {ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import type {XDSBaseProps} from '../XDSBaseProps';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
export interface XDSTableFooterProps extends XDSBaseProps<HTMLTableSectionElement> {
ref?: React.Ref<HTMLTableSectionElement>;
@@ -16,7 +17,7 @@ export function XDSTableFooter({ref, children, xstyle}: XDSTableFooterProps) {
return (
<tfoot
ref={ref}
- {...mergeProps(xdsClassName('table-footer'), stylex.props(xstyle))}>
+ {...mergeProps(xdsThemeProps('table-footer'), stylex.props(xstyle))}>
{children}
</tfoot>
);
diff --git a/packages/core/src/Table/XDSTableHeader.tsx b/packages/core/src/Table/XDSTableHeader.tsx
index 64e566a648..d17c8be41a 100644
--- a/packages/core/src/Table/XDSTableHeader.tsx
+++ b/packages/core/src/Table/XDSTableHeader.tsx
@@ -5,7 +5,8 @@ import type React from 'react';
import type {ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import type {XDSBaseProps} from '../XDSBaseProps';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
export interface XDSTableHeaderProps extends XDSBaseProps<HTMLTableSectionElement> {
ref?: React.Ref<HTMLTableSectionElement>;
@@ -16,7 +17,7 @@ export function XDSTableHeader({ref, children, xstyle}: XDSTableHeaderProps) {
return (
<thead
ref={ref}
- {...mergeProps(xdsClassName('table-header'), stylex.props(xstyle))}>
+ {...mergeProps(xdsThemeProps('table-header'), stylex.props(xstyle))}>
{children}
</thead>
);
diff --git a/packages/core/src/Table/XDSTableHeaderCell.tsx b/packages/core/src/Table/XDSTableHeaderCell.tsx
index bbaeb2cab7..952e63bb8f 100644
--- a/packages/core/src/Table/XDSTableHeaderCell.tsx
+++ b/packages/core/src/Table/XDSTableHeaderCell.tsx
@@ -27,7 +27,8 @@ import {
import type {StyleXStyles} from '../theme/types';
import {overflowStyles, containerEdgeStyles} from './table.stylex';
import {useTableContext, mergeXStyle} from './useTableCellStyles';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
/** Props for XDSTableHeaderCell — `<th>` wrapper with context-aware styling */
export interface XDSTableHeaderCellProps extends XDSBaseProps<HTMLTableCellElement> {
@@ -126,7 +127,7 @@ export function XDSTableHeaderCell({
ref={ref}
{...props}
{...mergeProps(
- xdsClassName('table-header-cell'),
+ xdsThemeProps('table-header-cell'),
stylex.props(xstyle),
incomingClassName,
incomingStyle,
@@ -157,7 +158,7 @@ export function XDSTableHeaderCell({
ref={ref}
{...props}
{...mergeProps(
- xdsClassName('table-header-cell'),
+ xdsThemeProps('table-header-cell'),
stylex.props(...mergeXStyle(cellStyles, xstyle)),
incomingClassName,
incomingStyle,
diff --git a/packages/core/src/Table/XDSTableRow.tsx b/packages/core/src/Table/XDSTableRow.tsx
index bcde32eaaa..0b548630cc 100644
--- a/packages/core/src/Table/XDSTableRow.tsx
+++ b/packages/core/src/Table/XDSTableRow.tsx
@@ -21,7 +21,8 @@ import {colorVars, durationVars, easeVars} from '../theme/tokens.stylex';
import type {StyleXStyles} from '../theme/types';
import {tableRowMarker} from './table.stylex';
import {XDSTableContext} from './XDSTableContext';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
/** Props for XDSTableRow — thin `<tr>` wrapper */
export interface XDSTableRowProps extends XDSBaseProps<HTMLTableRowElement> {
@@ -103,7 +104,7 @@ export function XDSTableRow({
ref={ref}
{...props}
{...mergeProps(
- xdsClassName('table-row'),
+ xdsThemeProps('table-row'),
stylex.props(tableRowMarker, xstyle),
)}>
{children}
@@ -136,7 +137,7 @@ export function XDSTableRow({
ref={ref}
{...props}
{...mergeProps(
- xdsClassName('table-row'),
+ xdsThemeProps('table-row'),
stylex.props(tableRowMarker, ...rowStyles),
)}>
{children}
diff --git a/packages/core/src/Text/XDSText.tsx b/packages/core/src/Text/XDSText.tsx
index 2ef471be98..3908343189 100644
--- a/packages/core/src/Text/XDSText.tsx
+++ b/packages/core/src/Text/XDSText.tsx
@@ -46,8 +46,9 @@ import {
} from './text.stylex';
import {useTruncation} from './useTruncation';
import type {LayerPlacement} from '../Layer';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const LazyXDSTooltip = lazy(async () =>
import('../Tooltip/XDSTooltip').then(mod => ({default: mod.XDSTooltip})),
@@ -253,7 +254,7 @@ export function XDSText({
<Component
ref={mergeRefs(ref, truncation.ref, textRef)}
{...mergeProps(
- xdsClassName('text', {type, color: resolvedColor}),
+ xdsThemeProps('text', {type, color: resolvedColor}),
stylex.props(
colorStyles[resolvedColor],
sizeByTypeStyles[styleType],
diff --git a/packages/core/src/Text/text.stylex.ts b/packages/core/src/Text/text.stylex.ts
index e184ed891b..bdd9c48558 100644
--- a/packages/core/src/Text/text.stylex.ts
+++ b/packages/core/src/Text/text.stylex.ts
@@ -100,7 +100,8 @@ export const defaultWeightByTypeStyles = stylex.create({
// Baseline Size/Leading by Type (from type-scale tokens)
//
// These ensure XDSText renders with correct sizing even without a theme.
-// Theme component overrides (.xds-text.body { ... }) win when present
+// Theme component overrides (.xds-text.body { ... } today, plus data-type
+// reflection on rendered text elements) win when present
// because they have higher specificity via @scope.
// =============================================================================
diff --git a/packages/core/src/TextArea/XDSTextArea.tsx b/packages/core/src/TextArea/XDSTextArea.tsx
index 22c34491c0..a74d2a7f19 100644
--- a/packages/core/src/TextArea/XDSTextArea.tsx
+++ b/packages/core/src/TextArea/XDSTextArea.tsx
@@ -43,10 +43,11 @@ import {
} from '../Field';
import {XDSIcon, renderIconSlot, type XDSIconType} from '../Icon';
import {XDSSpinner} from '../Spinner';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
import {useInputContainer} from '../hooks/useInputContainer';
import {useXDSSize} from '../SizeContext/XDSSizeContext';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const COUNTER_WARNING_THRESHOLD = 0.8;
@@ -375,7 +376,7 @@ export function XDSTextArea({
onClick={handleWrapperClick}
onMouseUp={handleWrapperMouseUp}
{...mergeProps(
- xdsClassName('textarea', {size, status: status?.type ?? null}),
+ xdsThemeProps('textarea', {size, status: status?.type ?? null}),
stylex.props(
inputWrapperStyles.base,
styles.wrapper,
diff --git a/packages/core/src/TextInput/XDSTextInput.tsx b/packages/core/src/TextInput/XDSTextInput.tsx
index da014c1a2b..70e2582d28 100644
--- a/packages/core/src/TextInput/XDSTextInput.tsx
+++ b/packages/core/src/TextInput/XDSTextInput.tsx
@@ -113,11 +113,12 @@ export type {
XDSInputStatus as XDSTextInputStatus,
XDSInputStatusType as XDSTextInputStatusType,
} from '../Field';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import {useXDSSize} from '../SizeContext/XDSSizeContext';
import {useInputContainer} from '../hooks/useInputContainer';
import {useXDSInputGroup} from '../InputGroup/XDSInputGroupContext';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
export type XDSTextInputType = 'text' | 'password' | 'email';
@@ -331,7 +332,7 @@ export function XDSTextInput({
onClick={handleWrapperClick}
onMouseUp={handleWrapperMouseUp}
{...mergeProps(
- xdsClassName('text-input', {size, status: status?.type ?? null}),
+ xdsThemeProps('text-input', {size, status: status?.type ?? null}),
stylex.props(
inputWrapperStyles.base,
sizeStyles[size],
diff --git a/packages/core/src/Thumbnail/XDSThumbnail.tsx b/packages/core/src/Thumbnail/XDSThumbnail.tsx
index f17238684c..1720714c5a 100644
--- a/packages/core/src/Thumbnail/XDSThumbnail.tsx
+++ b/packages/core/src/Thumbnail/XDSThumbnail.tsx
@@ -38,7 +38,8 @@ import {XDSTooltip} from '../Tooltip/XDSTooltip';
import {XDSMediaTheme} from '../theme/XDSMediaTheme';
import {useImageMode} from '../hooks/useImageMode';
import type {XDSBaseProps} from '../XDSBaseProps';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
/** Sample the region behind the remove button (20px button, 4px inset, in 64px container). */
const BUTTON_REGION = {x: 0.5, y: 0.06, width: 0.44, height: 0.44};
@@ -297,7 +298,7 @@ export function XDSThumbnail({
data-testid={testId}
aria-label={accessibleName}
{...mergeProps(
- xdsClassName('thumbnail'),
+ xdsThemeProps('thumbnail'),
stylex.props(styles.root, isDisabled && styles.disabled, xstyle),
className,
style,
diff --git a/packages/core/src/TimeInput/XDSTimeInput.tsx b/packages/core/src/TimeInput/XDSTimeInput.tsx
index 1ac35cc71d..b5ce1b5703 100644
--- a/packages/core/src/TimeInput/XDSTimeInput.tsx
+++ b/packages/core/src/TimeInput/XDSTimeInput.tsx
@@ -56,13 +56,13 @@ import {
formatISOTime,
adjustTime,
isTimeInRange,
- xdsClassName,
mergeProps,
mergeRefs,
} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
import {useXDSSize} from '../SizeContext/XDSSizeContext';
import {useInputContainer} from '../hooks/useInputContainer';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const styles = stylex.create({
icon: {
@@ -526,7 +526,7 @@ export function XDSTimeInput({
onClick={handleWrapperClick}
onMouseUp={handleWrapperMouseUp}
{...mergeProps(
- xdsClassName('time-input', {size, status: status?.type ?? null}),
+ xdsThemeProps('time-input', {size, status: status?.type ?? null}),
stylex.props(
inputWrapperStyles.base,
sizeStyles[size],
diff --git a/packages/core/src/Timestamp/XDSTimestamp.tsx b/packages/core/src/Timestamp/XDSTimestamp.tsx
index 2bd44a6731..f51d613f93 100644
--- a/packages/core/src/Timestamp/XDSTimestamp.tsx
+++ b/packages/core/src/Timestamp/XDSTimestamp.tsx
@@ -25,8 +25,9 @@ import type {
XDSTextColor,
XDSTextWeight,
} from '../theme/types';
-import {xdsClassName, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const LazyXDSTooltip = lazy(async () =>
import('../Tooltip/XDSTooltip').then(mod => ({default: mod.XDSTooltip})),
@@ -377,7 +378,10 @@ export function XDSTimestamp({
const showTooltip = hasTooltip && effectiveFormat === 'relative';
- const timestampClass = xdsClassName('timestamp', {format: effectiveFormat});
+ const timestampProps = mergeProps(
+ xdsThemeProps('timestamp', {format: effectiveFormat}),
+ {className, style},
+ );
const timeElement = (
<XDSText
@@ -386,8 +390,7 @@ export function XDSTimestamp({
color={color}
weight={weight}
xstyle={xstyle}
- className={[timestampClass, className].filter(Boolean).join(' ')}
- style={style}>
+ {...timestampProps}>
<time
ref={mergeRefs(ref, timeRef)}
dateTime={isoString}
diff --git a/packages/core/src/Toast/XDSToast.tsx b/packages/core/src/Toast/XDSToast.tsx
index 26176e8d6d..c66861ca52 100644
--- a/packages/core/src/Toast/XDSToast.tsx
+++ b/packages/core/src/Toast/XDSToast.tsx
@@ -17,10 +17,11 @@ import {
typographyVars,
typeScaleDefaults,
} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {useXDSTheme} from '../theme';
import {XDSMediaTheme} from '../theme/XDSMediaTheme';
import type {XDSToastType, XDSToastDismissReason} from './types';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
const styles = stylex.create({
root: {
@@ -186,7 +187,7 @@ export function XDSToast({
onFocusCapture={pauseTimer}
onBlurCapture={resumeTimer}
{...mergeProps(
- xdsClassName('toast', {type}),
+ xdsThemeProps('toast', {type}),
stylex.props(
styles.root,
isError ? styles.variantError : styles.variantDefault,
diff --git a/packages/core/src/ToggleButton/XDSToggleButton.tsx b/packages/core/src/ToggleButton/XDSToggleButton.tsx
index 3b8781253f..33b9c25664 100644
--- a/packages/core/src/ToggleButton/XDSToggleButton.tsx
+++ b/packages/core/src/ToggleButton/XDSToggleButton.tsx
@@ -23,10 +23,11 @@
import React, {useCallback, type ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import {colorVars, fontWeightVars} from '../theme/tokens.stylex';
-import {xdsClassName} from '../utils';
+
import {XDSButton, type XDSButtonSize} from '../Button';
import {useXDSToggleButtonGroup} from './XDSToggleButtonGroup';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Styles
@@ -293,7 +294,7 @@ export function XDSToggleButton({
aria-pressed={isPressed}
icon={resolvedIcon}
tooltip={tooltip}
- className={xdsClassName('toggle-button', {
+ {...xdsThemeProps('toggle-button', {
isPressed: isPressed ? 'true' : 'false',
})}
xstyle={[isPressed ? pressedStyles.background : undefined, xstyle]}
diff --git a/packages/core/src/ToggleButton/XDSToggleButtonGroup.tsx b/packages/core/src/ToggleButton/XDSToggleButtonGroup.tsx
index eacbae2c82..ee0e711829 100644
--- a/packages/core/src/ToggleButton/XDSToggleButtonGroup.tsx
+++ b/packages/core/src/ToggleButton/XDSToggleButtonGroup.tsx
@@ -22,8 +22,9 @@ import {createContext, useCallback, use, useMemo, type ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import {spacingVars} from '../theme/tokens.stylex';
import type {XDSButtonSize} from '../Button';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {StyleXStyles} from '@stylexjs/stylex';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Context
@@ -230,7 +231,7 @@ export function XDSToggleButtonGroup(
aria-label={label}
data-testid={testId}
{...mergeProps(
- xdsClassName('toggle-button-group'),
+ xdsThemeProps('toggle-button-group'),
stylex.props(
styles.group,
orientation === 'vertical' && styles.vertical,
diff --git a/packages/core/src/Token/XDSToken.tsx b/packages/core/src/Token/XDSToken.tsx
index 5c51f5ed0c..d9a8affad7 100644
--- a/packages/core/src/Token/XDSToken.tsx
+++ b/packages/core/src/Token/XDSToken.tsx
@@ -29,10 +29,11 @@ import {
typeScaleVars,
} from '../theme/tokens.stylex';
import {XDSIcon} from '../Icon';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {useXDSLinkComponent} from '../Link/useXDSLinkComponent';
import {useXDSInteractiveRole} from '../hooks/useXDSInteractiveRole';
import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Types
@@ -368,7 +369,7 @@ export function XDSToken({
aria-disabled={isDisabled || undefined}
{...sharedProps}
{...mergeProps(
- xdsClassName('token', {color, size}),
+ xdsThemeProps('token', {color, size}),
stylex.props(
styles.base,
sizeStyles[size],
@@ -400,7 +401,7 @@ export function XDSToken({
onClick={isDisabled ? undefined : handleContainerClick}
{...sharedProps}
{...mergeProps(
- xdsClassName('token', {color, size}),
+ xdsThemeProps('token', {color, size}),
stylex.props(
styles.base,
sizeStyles[size],
@@ -450,7 +451,7 @@ export function XDSToken({
ref={ref}
{...sharedProps}
{...mergeProps(
- xdsClassName('token', {color, size}),
+ xdsThemeProps('token', {color, size}),
stylex.props(
styles.base,
sizeStyles[size],
diff --git a/packages/core/src/Tokenizer/XDSTokenizer.tsx b/packages/core/src/Tokenizer/XDSTokenizer.tsx
index 54fce63468..5602345242 100644
--- a/packages/core/src/Tokenizer/XDSTokenizer.tsx
+++ b/packages/core/src/Tokenizer/XDSTokenizer.tsx
@@ -48,7 +48,8 @@ import {
typeScaleVars,
} from '../theme/tokens.stylex';
import type {XDSSearchableItem, XDSSearchSource} from '../Typeahead/types';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// Re-export status types for convenience
export type {
@@ -655,7 +656,7 @@ export function XDSTokenizer<T extends XDSSearchableItem>({
onBlurCapture={handleBlurCapture}
data-testid={testId}
{...mergeProps(
- xdsClassName('tokenizer', {size, status: status?.type}),
+ xdsThemeProps('tokenizer', {size, status: status?.type}),
stylex.props(
inputWrapperStyles.base,
styles.wrapper,
@@ -740,7 +741,7 @@ export function XDSTokenizer<T extends XDSSearchableItem>({
ref={placeholderRef}
onClick={handleWrapperClick}
{...mergeProps(
- xdsClassName('tokenizer', {size, status: status?.type}),
+ xdsThemeProps('tokenizer', {size, status: status?.type}),
stylex.props(
inputWrapperStyles.base,
styles.wrapper,
diff --git a/packages/core/src/Toolbar/XDSToolbar.tsx b/packages/core/src/Toolbar/XDSToolbar.tsx
index 70d42ccfc3..5465d5dbc5 100644
--- a/packages/core/src/Toolbar/XDSToolbar.tsx
+++ b/packages/core/src/Toolbar/XDSToolbar.tsx
@@ -23,11 +23,12 @@ import type {SpacingStep} from '../utils/types';
import type {XDSElementSize} from '../SizeContext/XDSSizeContext';
import * as stylex from '@stylexjs/stylex';
import {spacingVars, sizeVars} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {XDSSection} from '../Section/XDSSection';
import {useListFocus} from '../hooks/useListFocus';
import {XDSSizeProvider} from '../SizeContext/XDSSizeContext';
import {edgeCompSlot} from '../Layout/edgeCompensation.stylex';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
/**
* Map SpacingStep values to spacingVars keys.
@@ -256,7 +257,7 @@ export function XDSToolbar({
aria-orientation={orientation}
onKeyDown={handleKeyDown}
{...mergeProps(
- xdsClassName('toolbar', {size}),
+ xdsThemeProps('toolbar', {size}),
stylex.props(
hasCenterContent ? styles.baseGrid : styles.baseFlex,
orientation === 'vertical' && styles.vertical,
diff --git a/packages/core/src/Tooltip/useXDSTooltip.tsx b/packages/core/src/Tooltip/useXDSTooltip.tsx
index 4b7117c96a..14737ea62e 100644
--- a/packages/core/src/Tooltip/useXDSTooltip.tsx
+++ b/packages/core/src/Tooltip/useXDSTooltip.tsx
@@ -28,6 +28,7 @@ import {
type LayerPlacement,
} from '../Layer/useXDSLayer';
import {layerAnimations} from '../Layer/layerAnimations.stylex';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
import {
colorVars,
radiusVars,
@@ -35,7 +36,6 @@ import {
typographyVars,
typeScaleVars,
} from '../theme/tokens.stylex';
-import {xdsClassName} from '../utils';
const styles = stylex.create({
// Base container styles - inverted colors for high contrast
@@ -430,7 +430,7 @@ export function useXDSTooltip(
placement: renderPlacement,
alignment: props?.alignment ?? alignment,
xstyle: [popoverXstyle, layerAnimations[renderPlacement]],
- className: xdsClassName('tooltip'),
+ className: xdsThemeProps('tooltip').className,
};
return layer.render(
diff --git a/packages/core/src/TopNav/XDSTopNav.tsx b/packages/core/src/TopNav/XDSTopNav.tsx
index 410b106f70..48d41aa8ad 100644
--- a/packages/core/src/TopNav/XDSTopNav.tsx
+++ b/packages/core/src/TopNav/XDSTopNav.tsx
@@ -20,7 +20,7 @@ import type {ReactNode} from 'react';
import type {XDSBaseProps} from '../XDSBaseProps';
import * as stylex from '@stylexjs/stylex';
import {spacingVars} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {XDSTopNavSlotContext} from './TopNavContext';
import {useXDSTopNavRenderMode} from './XDSTopNavRenderContext';
import {useXDSTopNavMobileContent} from './XDSTopNavMobileContentContext';
@@ -28,6 +28,7 @@ import {XDSDivider} from '../Divider/XDSDivider';
import {XDSMobileNav} from '../MobileNav/XDSMobileNav';
import {XDSMobileNavToggle} from '../MobileNav/XDSMobileNavToggle';
import {useXDSAppShellMobile} from '../AppShell/XDSAppShellMobileContext';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
/**
* Base TopNav styles
@@ -204,7 +205,7 @@ export function XDSTopNav({
role="navigation"
aria-label={label}
{...mergeProps(
- xdsClassName('top-nav', {mode: 'mobile-bar'}),
+ xdsThemeProps('top-nav', {mode: 'mobile-bar'}),
stylex.props(styles.mobileBar, xstyle),
className,
style,
@@ -261,7 +262,7 @@ export function XDSTopNav({
role="navigation"
aria-label={label}
{...mergeProps(
- xdsClassName('top-nav'),
+ xdsThemeProps('top-nav'),
stylex.props(
styles.base,
hasCenterContent ? styles.baseGrid : styles.baseFlex,
diff --git a/packages/core/src/TopNav/XDSTopNavHeading.tsx b/packages/core/src/TopNav/XDSTopNavHeading.tsx
index 19b2f571ee..0ad43c4be2 100644
--- a/packages/core/src/TopNav/XDSTopNavHeading.tsx
+++ b/packages/core/src/TopNav/XDSTopNavHeading.tsx
@@ -34,10 +34,11 @@ import {XDSLink} from '../Link';
import {getIcon} from '../Icon/globalIconRegistry';
import {useXDSLinkComponent} from '../Link/useXDSLinkComponent';
import type {XDSLinkComponentType} from '../Link/types';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
import {useXDSMenuHover} from '../hooks/useXDSMenuHover';
import {XDSNavHeadingCloseContext} from '../NavMenu/XDSNavMenuContext';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Styles
@@ -426,7 +427,7 @@ export function XDSTopNavHeading({
href={headingHref}
data-testid={testId}
{...mergeProps(
- xdsClassName('top-nav-heading'),
+ xdsThemeProps('top-nav-heading'),
stylex.props(
styles.root,
!!headingHref && styles.menuTrigger,
@@ -449,7 +450,7 @@ export function XDSTopNavHeading({
href={headingHref}
data-testid={testId}
{...mergeProps(
- xdsClassName('top-nav-heading'),
+ xdsThemeProps('top-nav-heading'),
stylex.props(styles.root, styles.menuTrigger, xstyle),
className,
style,
@@ -472,7 +473,7 @@ export function XDSTopNavHeading({
data-testid={testId}
{...triggerProps}
{...mergeProps(
- xdsClassName('top-nav-heading'),
+ xdsThemeProps('top-nav-heading'),
stylex.props(styles.root, styles.menuTrigger, xstyle),
className,
style,
@@ -523,7 +524,7 @@ export function XDSTopNavHeading({
data-testid={testId}
{...triggerProps}
{...mergeProps(
- xdsClassName('top-nav-heading'),
+ xdsThemeProps('top-nav-heading'),
stylex.props(styles.root, xstyle),
className,
style,
@@ -584,7 +585,7 @@ export function XDSTopNavHeading({
ref={ref as React.Ref<HTMLDivElement>}
data-testid={testId}
{...mergeProps(
- xdsClassName('top-nav-heading'),
+ xdsThemeProps('top-nav-heading'),
stylex.props(styles.root, xstyle),
className,
style,
@@ -635,7 +636,7 @@ export function XDSTopNavHeading({
ref={ref as React.Ref<HTMLDivElement>}
data-testid={testId}
{...mergeProps(
- xdsClassName('top-nav-heading'),
+ xdsThemeProps('top-nav-heading'),
stylex.props(styles.root, xstyle),
className,
style,
diff --git a/packages/core/src/TopNav/XDSTopNavItem.tsx b/packages/core/src/TopNav/XDSTopNavItem.tsx
index 1fb1870746..76e0e27e12 100644
--- a/packages/core/src/TopNav/XDSTopNavItem.tsx
+++ b/packages/core/src/TopNav/XDSTopNavItem.tsx
@@ -32,8 +32,9 @@ import {useXDSLinkComponent} from '../Link/useXDSLinkComponent';
import type {XDSLinkComponentType} from '../Link/types';
import {useXDSTopNavRenderMode} from './XDSTopNavRenderContext';
import {navItemStyles, type NavItemSize} from '../NavItem/navItemStyles.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {useXDSAppShellMobile} from '../AppShell/XDSAppShellMobileContext';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
/**
* NavItem styles with hover/selected states
@@ -215,7 +216,7 @@ export function XDSTopNavItem({
aria-disabled={isDisabled || undefined}
tabIndex={isDisabled ? -1 : undefined}
{...mergeProps(
- xdsClassName('top-nav-item', {
+ xdsThemeProps('top-nav-item', {
mode: 'drawer',
selected: isSelected ? 'selected' : null,
}),
@@ -250,7 +251,7 @@ export function XDSTopNavItem({
aria-disabled={isDisabled || undefined}
tabIndex={isDisabled ? -1 : undefined}
{...mergeProps(
- xdsClassName('top-nav-item', {
+ xdsThemeProps('top-nav-item', {
selected: isSelected ? 'selected' : null,
}),
stylex.props(
diff --git a/packages/core/src/TopNav/XDSTopNavMegaMenu.tsx b/packages/core/src/TopNav/XDSTopNavMegaMenu.tsx
index 59cbe20515..205cbf33a6 100644
--- a/packages/core/src/TopNav/XDSTopNavMegaMenu.tsx
+++ b/packages/core/src/TopNav/XDSTopNavMegaMenu.tsx
@@ -45,11 +45,12 @@ import {
import {useXDSPopover} from '../Popover/useXDSPopover';
import {XDSGrid} from '../Grid/XDSGrid';
import {getIcon} from '../Icon/globalIconRegistry';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
import {navItemStyles} from '../NavItem/navItemStyles.stylex';
import {useTopNavSlot} from './TopNavContext';
import {useXDSTopNavRenderMode} from './XDSTopNavRenderContext';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Styles
@@ -439,7 +440,7 @@ function DefaultMegaMenu({
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
{...mergeProps(
- xdsClassName('top-nav-mega-menu'),
+ xdsThemeProps('top-nav-mega-menu'),
stylex.props(styles.trigger, popover.isOpen && styles.triggerOpen),
)}>
{label}
@@ -505,7 +506,7 @@ function DrawerMegaMenu({
aria-expanded={isExpanded}
aria-controls={`${menuId}-items`}
{...mergeProps(
- xdsClassName('top-nav-mega-menu', {mode: 'drawer'}),
+ xdsThemeProps('top-nav-mega-menu', {mode: 'drawer'}),
stylex.props(navItemStyles.item, styles.drawerHeader),
)}>
{label}
diff --git a/packages/core/src/TopNav/XDSTopNavMegaMenuFeaturedCard.tsx b/packages/core/src/TopNav/XDSTopNavMegaMenuFeaturedCard.tsx
index 1245cd9bf3..e8d7f3084e 100644
--- a/packages/core/src/TopNav/XDSTopNavMegaMenuFeaturedCard.tsx
+++ b/packages/core/src/TopNav/XDSTopNavMegaMenuFeaturedCard.tsx
@@ -26,9 +26,10 @@ import {
typeScaleVars,
fontWeightVars,
} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
import {useXDSLinkComponent} from '../Link/useXDSLinkComponent';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Styles
@@ -137,7 +138,7 @@ export function XDSTopNavMegaMenuFeaturedCard({
<div
ref={ref}
{...mergeProps(
- xdsClassName('top-nav-mega-menu-featured-card'),
+ xdsThemeProps('top-nav-mega-menu-featured-card'),
stylex.props(styles.root),
)}>
{image && (
diff --git a/packages/core/src/TopNav/XDSTopNavMegaMenuItem.tsx b/packages/core/src/TopNav/XDSTopNavMegaMenuItem.tsx
index 7414f59fbd..fce90286d3 100644
--- a/packages/core/src/TopNav/XDSTopNavMegaMenuItem.tsx
+++ b/packages/core/src/TopNav/XDSTopNavMegaMenuItem.tsx
@@ -30,9 +30,10 @@ import {navItemStyles} from '../NavItem/navItemStyles.stylex';
import {useXDSLinkComponent} from '../Link/useXDSLinkComponent';
import type {XDSLinkComponentType} from '../Link/types';
import {useXDSTopNavRenderMode} from './XDSTopNavRenderContext';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
import {useXDSAppShellMobile} from '../AppShell/XDSAppShellMobileContext';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Styles
@@ -220,7 +221,7 @@ export function XDSTopNavMegaMenuItem({
onClick={handleDrawerClick}
{...elementProps}
{...mergeProps(
- xdsClassName('top-nav-mega-menu-item', {mode: 'drawer'}),
+ xdsThemeProps('top-nav-mega-menu-item', {mode: 'drawer'}),
stylex.props(navItemStyles.item, styles.drawerItem),
)}>
{icon && <div {...stylex.props(styles.drawerItemIcon)}>{icon}</div>}
@@ -247,7 +248,7 @@ export function XDSTopNavMegaMenuItem({
onClick={onClick}
tabIndex={tabIndex}
{...mergeProps(
- xdsClassName('top-nav-mega-menu-item'),
+ xdsThemeProps('top-nav-mega-menu-item'),
stylex.props(styles.desktop),
)}>
{icon && <div {...stylex.props(styles.desktopIcon)}>{icon}</div>}
diff --git a/packages/core/src/TopNav/XDSTopNavMenu.tsx b/packages/core/src/TopNav/XDSTopNavMenu.tsx
index f121b2dd53..97ddd5c0d7 100644
--- a/packages/core/src/TopNav/XDSTopNavMenu.tsx
+++ b/packages/core/src/TopNav/XDSTopNavMenu.tsx
@@ -20,13 +20,14 @@ import * as stylex from '@stylexjs/stylex';
import {useXDSPopover} from '../Popover/useXDSPopover';
import {useXDSMenuHover} from '../hooks/useXDSMenuHover';
import {getIcon} from '../Icon/globalIconRegistry';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
import {navItemStyles} from '../NavItem/navItemStyles.stylex';
import {useTopNavSlot} from './TopNavContext';
import {useXDSTopNavRenderMode} from './XDSTopNavRenderContext';
import {useXDSAppShellMobile} from '../AppShell/XDSAppShellMobileContext';
import {useXDSLinkComponent} from '../Link/useXDSLinkComponent';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
import {
colorVars,
spacingVars,
@@ -422,7 +423,7 @@ export function XDSTopNavMenu({
{...popover.triggerProps}
{...triggerProps}
{...mergeProps(
- xdsClassName('top-nav-menu'),
+ xdsThemeProps('top-nav-menu'),
stylex.props(styles.trigger, popover.isOpen && styles.triggerOpen),
)}>
{label}
diff --git a/packages/core/src/TreeList/XDSTreeList.tsx b/packages/core/src/TreeList/XDSTreeList.tsx
index 905ce0a3e5..41f18d3a05 100644
--- a/packages/core/src/TreeList/XDSTreeList.tsx
+++ b/packages/core/src/TreeList/XDSTreeList.tsx
@@ -18,10 +18,11 @@
import {useId, useState, useMemo, useCallback, type ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import {spacingVars} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
import {XDSTreeListItem} from './XDSTreeListItem';
import type {XDSTreeListItemData, XDSTreeListDensity} from './XDSTreeListTypes';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Types
@@ -215,7 +216,7 @@ export function XDSTreeList({
ref={ref}
data-testid={testId}
{...mergeProps(
- xdsClassName('tree-list', {density}),
+ xdsThemeProps('tree-list', {density}),
stylex.props(styles.root, xstyle),
className,
style,
diff --git a/packages/core/src/TreeList/XDSTreeListItem.tsx b/packages/core/src/TreeList/XDSTreeListItem.tsx
index ea7347c700..118eccaad9 100644
--- a/packages/core/src/TreeList/XDSTreeListItem.tsx
+++ b/packages/core/src/TreeList/XDSTreeListItem.tsx
@@ -25,10 +25,11 @@ import {
typeScaleVars,
} from '../theme/tokens.stylex';
import {getIcon} from '../Icon/globalIconRegistry';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import {useXDSLinkComponent} from '../Link/useXDSLinkComponent';
import {XDSTreeListBranches} from './XDSTreeListBranches';
import type {XDSTreeListDensity} from './XDSTreeListTypes';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Styles
@@ -410,7 +411,7 @@ export function XDSTreeListItem({
<div {...stylex.props(styles.rowWrapper)}>
<div
{...mergeProps(
- xdsClassName('tree-list-item', {
+ xdsThemeProps('tree-list-item', {
density,
selected: isSelected ? 'selected' : null,
disabled: isDisabled ? 'disabled' : null,
diff --git a/packages/core/src/Typeahead/XDSBaseTypeahead.tsx b/packages/core/src/Typeahead/XDSBaseTypeahead.tsx
index 875ace63b7..af6014d41d 100644
--- a/packages/core/src/Typeahead/XDSBaseTypeahead.tsx
+++ b/packages/core/src/Typeahead/XDSBaseTypeahead.tsx
@@ -39,9 +39,10 @@ import {
fontWeightVars,
typeScaleVars,
} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
import type {XDSSearchableItem, XDSSearchSource} from './types';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Types
@@ -680,7 +681,7 @@ export const XDSBaseTypeahead = function XDSBaseTypeahead<
role="listbox"
aria-label="Search results"
{...mergeProps(
- xdsClassName('typeahead-dropdown'),
+ xdsThemeProps('typeahead-dropdown'),
stylex.props(styles.dropdown),
)}>
{results.length === 0 && hasSearched ? (
diff --git a/packages/core/src/Typeahead/XDSTypeahead.tsx b/packages/core/src/Typeahead/XDSTypeahead.tsx
index 52486e5b3b..87a5ebc658 100644
--- a/packages/core/src/Typeahead/XDSTypeahead.tsx
+++ b/packages/core/src/Typeahead/XDSTypeahead.tsx
@@ -40,9 +40,10 @@ import {
import {XDSToken} from '../Token';
import {renderIconSlot, type XDSIconType} from '../Icon';
import {spacingVars, sizeVars} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
import type {XDSBaseProps} from '../XDSBaseProps';
import type {XDSSearchableItem, XDSSearchSource} from './types';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
export type {
XDSInputStatus as XDSTypeaheadStatus,
@@ -366,7 +367,7 @@ export function XDSTypeahead<T extends XDSSearchableItem>({
onClick={handleWrapperClick}
onBlur={handleBlur}
{...mergeProps(
- xdsClassName('typeahead', {size, status: status?.type}),
+ xdsThemeProps('typeahead', {size, status: status?.type}),
stylex.props(
inputWrapperStyles.base,
styles.wrapper,
diff --git a/packages/core/src/Typeahead/XDSTypeaheadItem.tsx b/packages/core/src/Typeahead/XDSTypeaheadItem.tsx
index 6419f410ba..9dc77ac01b 100644
--- a/packages/core/src/Typeahead/XDSTypeaheadItem.tsx
+++ b/packages/core/src/Typeahead/XDSTypeaheadItem.tsx
@@ -21,7 +21,8 @@ import {
} from '../theme/tokens.stylex';
import type {XDSSearchableItem} from './types';
import type {XDSBaseProps} from '../XDSBaseProps';
-import {xdsClassName, mergeProps} from '../utils';
+import {mergeProps} from '../utils';
+import {xdsThemeProps} from '../utils/xdsThemeProps';
// =============================================================================
// Types
@@ -141,7 +142,7 @@ export function XDSTypeaheadItem<T extends XDSSearchableItem>({
<div
ref={ref}
{...mergeProps(
- xdsClassName('typeahead-item'),
+ xdsThemeProps('typeahead-item'),
stylex.props(styles.container, isDisabled && styles.disabled),
)}>
{icon}
diff --git a/packages/core/src/XDSBaseProps.ts b/packages/core/src/XDSBaseProps.ts
index ee72554f49..ef9c7e23ee 100644
--- a/packages/core/src/XDSBaseProps.ts
+++ b/packages/core/src/XDSBaseProps.ts
@@ -89,6 +89,7 @@ export interface XDSBaseProps<T extends HTMLElement = HTMLElement> extends Omit<
*/
xstyle?: StyleXStyles;
- /** Allow data-* attributes for telemetry, testing, and integration hooks. */
+ /** Allow data-* attributes for telemetry, testing, integration hooks, and
+ * XDS component prop/state reflection (for example data-variant/data-size). */
[key: `data-${string}`]: string | undefined;
}
diff --git a/packages/core/src/docs-types.ts b/packages/core/src/docs-types.ts
index 4e206a3e55..f5a85b306c 100644
--- a/packages/core/src/docs-types.ts
+++ b/packages/core/src/docs-types.ts
@@ -73,9 +73,10 @@ export interface PropDoc {
}
/**
- * A theming target — a stable CSS class name that `defineTheme` can target
- * via `@scope` selectors. Each component renders one or more class names
- * via `xdsClassName()`, and themes can override styles for each.
+ * A theming target — a stable selector surface that `defineTheme` can target
+ * via `@scope` selectors. Each component renders one or more stable `xds-*`
+ * class names and reflects visual props/states as `data-*` attributes via
+ * `xdsThemeProps()`, so themes and external CSS have an explicit prop-aware selector surface.
*
* @example
* ```
@@ -89,16 +90,19 @@ export interface ThemingTarget {
* Always starts with `xds-`.
* e.g. `"xds-button"`, `"xds-avatar-status-dot"`, `"xds-card"` */
className: string;
- /** Visual prop names that produce variant classes on this element.
- * These are the props passed to `xdsClassName()` as the second argument.
- * Themes can target specific variants via `.xds-button.secondary`.
- * Omit if the component has no visual props (class name only). */
+ /** Visual prop names reflected on this element.
+ * These are the props passed to `xdsThemeProps()` as the second argument.
+ * Use these names to derive preferred data selectors: `variant` →
+ * `[data-variant="secondary"]`, `level` → `[data-level="2"]`. Legacy bare
+ * classes are still emitted for compatibility but should not be the primary
+ * documentation surface. Omit if the component has no visual props (class
+ * name only). */
visualProps?: string[];
- /** State class names that appear on this element based on component state.
+ /** State names that appear on this element based on component state.
* Unlike visualProps (driven by props), these reflect runtime state
- * (checked, selected, today, on, expanded, etc.).
- * Themes target them the same way as variants: `.xds-radio.checked { ... }`
- * Omit if the element has no state-driven classes. */
+ * (checked, selected, today, on, expanded, etc.). Use these names to derive preferred data selectors such as
+ * `[data-checked="checked"]`. Legacy state classes are still emitted for
+ * compatibility. Omit if the element has no state-driven selectors. */
states?: string[];
}
@@ -462,9 +466,9 @@ interface BaseDoc {
* only make sense within a parent (e.g. BreadcrumbItem, DialogHeader)
* or internal primitives that shouldn't appear in the gallery. */
isHiddenFromOverview?: boolean;
- /** Theming configuration. Documents the stable CSS class names
- * rendered by this component that themes can target via `@scope`
- * selectors in `defineTheme`. */
+ /** Theming configuration. Documents the stable selector surface rendered
+ * by this component: `xds-*` classes plus data-attribute reflections that
+ * themes can target via `@scope` selectors in `defineTheme`. */
theming?: {
/** Whether this component is a container whose `padding` properties
* should be mapped to container tokens by the theme pipeline.
@@ -472,8 +476,8 @@ interface BaseDoc {
* component overrides are expanded to `--container-padding-*` and
* `--layout-padding-*` tokens instead of emitting raw CSS. */
container?: boolean;
- /** CSS class targets rendered by this component.
- * Each entry corresponds to an `xdsClassName()` call in the source. */
+ /** Selector targets rendered by this component.
+ * Each entry corresponds to an `xdsThemeProps()` call in the source. */
targets: ThemingTarget[];
/** CSS custom properties exposed for theming. */
vars?: ComponentVar[];
diff --git a/packages/core/src/theme/XDSTheme.tsx b/packages/core/src/theme/XDSTheme.tsx
index dcae5f41a5..cdc19b2c0c 100644
--- a/packages/core/src/theme/XDSTheme.tsx
+++ b/packages/core/src/theme/XDSTheme.tsx
@@ -8,7 +8,9 @@
* Applies theme tokens and sets color-scheme for light-dark() to work.
* 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
+ * - Component overrides scoped via @scope'd CSS selectors on the stable XDS
+ * selector surface (`.xds-*` classes today; components also emit `data-*`
+ * prop reflections for the data-attribute selector migration)
*
* Root detection: The first XDSTheme in the tree (no parent XDSTheme)
* automatically syncs attributes to `document.documentElement`:
@@ -227,7 +229,8 @@ function useRootThemeSync(
*
* 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.
+ * components render with stable `.xds-*` classes plus `data-*` prop
+ * reflections and don't need context.
*
* When this is the root XDSTheme (no parent XDSTheme in the tree),
* it syncs `data-theme` and `data-xds-theme` to `<html>` so browser
diff --git a/packages/core/src/theme/generateThemeRules.ts b/packages/core/src/theme/generateThemeRules.ts
index bbcee81a98..40591311d0 100644
--- a/packages/core/src/theme/generateThemeRules.ts
+++ b/packages/core/src/theme/generateThemeRules.ts
@@ -231,7 +231,8 @@ export function generateThemeRules(theme: XDSDefinedTheme): string[] {
parts.push(` :scope {\n${declarations}\n }`);
}
- // 2. Component overrides (.xds-* class rules)
+ // 2. Component overrides (legacy .xds-* class rules; components also emit
+ // data-* prop reflections for external selector migrations)
if (theme.components) {
generateComponentRules(theme.components, parts);
}
@@ -248,7 +249,9 @@ export function generateThemeRules(theme: XDSDefinedTheme): string[] {
}
/**
- * Generate component .xds-* class override rules.
+ * Generate component override rules using the legacy .xds-* class selector
+ * format. Runtime components also emit matching data-* prop reflections; the
+ * theme CSS generator will move to data-attribute selectors in a later step.
* Handles derived var expansion and container padding mapping.
*/
function generateComponentRules(
@@ -259,11 +262,11 @@ function generateComponentRules(
parts: string[],
): void {
for (const [component, rules] of Object.entries(components)) {
- for (const [key, styles] of Object.entries(
- rules,
- )) {
+ for (const [key, styles] of Object.entries(rules)) {
const entries = Object.entries(styles);
- if (entries.length === 0) {continue;}
+ if (entries.length === 0) {
+ continue;
+ }
const suffix = parseStyleKey(key);
const baseSelector = `.xds-${component}${suffix}`;
@@ -497,7 +500,9 @@ export function generateOnMediaCSS(theme: XDSDefinedTheme): string {
>,
)) {
const entries = Object.entries(styles);
- if (entries.length === 0) {continue;}
+ if (entries.length === 0) {
+ continue;
+ }
const suffix = parseStyleKey(key);
const baseSelector = `[data-xds-media="${surface}"] .xds-${component}${suffix}`;
diff --git a/packages/core/src/utils/index.ts b/packages/core/src/utils/index.ts
index b28cf7a90d..bfff45382c 100644
--- a/packages/core/src/utils/index.ts
+++ b/packages/core/src/utils/index.ts
@@ -65,8 +65,6 @@ export type {ISOTimeString, ParsedTime} from './timeParser';
export {parseStyleKey} from './parseStyleKey';
-export {xdsClassName} from './xdsClassName';
-
export {mergeProps} from './mergeProps';
export {mergeRefs} from './mergeRefs';
export {groupItems, getItemGroup} from './groupItems';
diff --git a/packages/core/src/utils/mergeProps.ts b/packages/core/src/utils/mergeProps.ts
index f8ffea80b5..64148b6195 100644
--- a/packages/core/src/utils/mergeProps.ts
+++ b/packages/core/src/utils/mergeProps.ts
@@ -1,20 +1,21 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
/**
- * Merge xds-* class name, stylex.props result, and optional consumer className/style.
+ * Merge xds-* props, stylex.props result, and optional consumer className/style.
*
- * stylex.props() returns { className, style }. This merges the xds-*
- * class name into the className string so both StyleX styles and the
- * stable theme-targeting class are applied.
+ * stylex.props() returns { className, style }. This merges the XDS stable
+ * class name plus any data-attribute reflection from `xdsThemeProps()` with the
+ * StyleX class name so both StyleX styles and the theme-targeting surface are
+ * applied.
*
* Consumer className is appended after StyleX classes.
* Consumer style is spread after StyleX inline styles, so these values take priority.
*
* @example
* ```tsx
- * // Root element with xdsClassName
+ * // Root element with xdsThemeProps
* <div {...mergeProps(
- * xdsClassName('button', { variant }),
+ * xdsThemeProps('button', { variant }),
* stylex.props(styles.base, variants[variant]),
* className,
* style,
@@ -29,21 +30,48 @@
*/
type StyleObject = React.CSSProperties;
+type PropsObject = {
+ className?: string;
+ style?: StyleObject;
+ [key: string]: unknown;
+};
+
+function mergeTwoProps(base: PropsObject, overrides: PropsObject): PropsObject {
+ const merged: PropsObject = {...base, ...overrides};
+
+ const cls = [base.className, overrides.className].filter(Boolean).join(' ');
+ if (cls) {
+ merged.className = cls;
+ } else {
+ delete merged.className;
+ }
+
+ const mergedStyle =
+ overrides.style && base.style
+ ? {...base.style, ...overrides.style}
+ : overrides.style || base.style;
+ if (mergedStyle) {
+ merged.style = mergedStyle;
+ } else {
+ delete merged.style;
+ }
+
+ return merged;
+}
export function mergeProps(
- xdsClassOrStylexResult: string | {className?: string; style?: StyleObject},
- stylexResultOrClassName?: {className?: string; style?: StyleObject} | string,
+ xdsClassOrStylexResult: string | PropsObject,
+ stylexResultOrClassName?: PropsObject | string,
classNameOrStyle?: string | React.CSSProperties,
style?: React.CSSProperties,
-): {className: string; style?: StyleObject} {
+): PropsObject {
// Disambiguate: first arg is string → (xdsClass, stylexResult, className?, style?)
- // first arg is object → (stylexResult, overrides?, ...)
+ // first arg is object → merge arbitrary props (supports xdsThemeProps + data attrs).
if (typeof xdsClassOrStylexResult === 'string') {
const xdsClass = xdsClassOrStylexResult;
- const stylexResult = (stylexResultOrClassName as {
- className?: string;
- style?: StyleObject;
- }) ?? {className: ''};
+ const stylexResult = (stylexResultOrClassName as PropsObject) ?? {
+ className: '',
+ };
const className = classNameOrStyle as string | undefined;
let cls = stylexResult.className
@@ -58,26 +86,25 @@ export function mergeProps(
? {...stylexResult.style, ...style}
: style || stylexResult.style;
- return {className: cls, style: mergedStyle};
+ return {...stylexResult, className: cls, style: mergedStyle};
}
- // Object form: mergeProps(stylex.props(...), { style, className })
- const base = xdsClassOrStylexResult;
- const overrides =
- (stylexResultOrClassName as {
- className?: string;
- style?: StyleObject;
- }) ?? {};
+ const first = xdsClassOrStylexResult;
+ const second =
+ typeof stylexResultOrClassName === 'string'
+ ? {className: stylexResultOrClassName}
+ : (stylexResultOrClassName ?? {});
+ let merged = mergeTwoProps(first, second);
- let cls = base.className ?? '';
- if (overrides.className) {
- cls = cls ? `${cls} ${overrides.className}` : overrides.className;
+ if (typeof classNameOrStyle === 'string') {
+ merged = mergeTwoProps(merged, {className: classNameOrStyle});
+ } else if (classNameOrStyle != null) {
+ merged = mergeTwoProps(merged, {style: classNameOrStyle});
}
- const mergedStyle =
- overrides.style && base.style
- ? {...base.style, ...overrides.style}
- : overrides.style || base.style;
+ if (style != null) {
+ merged = mergeTwoProps(merged, {style});
+ }
- return {className: cls, style: mergedStyle};
+ return merged;
}
diff --git a/packages/core/src/utils/parseStyleKey.ts b/packages/core/src/utils/parseStyleKey.ts
index 48c8587527..484e5acaf1 100644
--- a/packages/core/src/utils/parseStyleKey.ts
+++ b/packages/core/src/utils/parseStyleKey.ts
@@ -7,10 +7,13 @@
* to ensure the same convention is applied consistently.
*
* <!-- SYNC: packages/cli/src/commands/build-theme.mjs (parseStyleKey) -->
- * <!-- SYNC: packages/core/src/utils/xdsClassName.ts -->
+ * <!-- SYNC: packages/core/src/utils/xdsThemeProps.ts -->
*
- * Uses class names for visual prop values — shorter HTML, easier to inspect.
- * The component class (e.g. .xds-button) disambiguates any value overlaps.
+ * Emits the legacy class-selector suffix used by defineTheme/component override
+ * generation today. Components also reflect the same prop values as data
+ * attributes via `xdsThemeProps()` (`variant:secondary` renders both `.secondary`
+ * and `[data-variant="secondary"]` in the DOM), but generated theme CSS still
+ * uses these class selectors until the selector contract migrates fully.
*
* Values starting with a digit get prefixed with the prop name since
* CSS class names can't start with a number.
diff --git a/packages/core/src/utils/xdsClassName.test.ts b/packages/core/src/utils/xdsClassName.test.ts
deleted file mode 100644
index 69b4e7699c..0000000000
--- a/packages/core/src/utils/xdsClassName.test.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright (c) Meta Platforms, Inc. and affiliates.
-
-import {describe, it, expect} from 'vitest';
-import {xdsClassName} from './xdsClassName';
-
-describe('xdsClassName', () => {
- it('returns base class for component', () => {
- expect(xdsClassName('card')).toBe('xds-card');
- });
-
- it('adds variant classes', () => {
- expect(xdsClassName('button', {variant: 'secondary', size: 'sm'})).toBe(
- 'xds-button secondary sm',
- );
- });
-
- it('prefixes numeric values with prop name', () => {
- expect(xdsClassName('heading', {level: 1})).toBe('xds-heading level-1');
- });
-
- it('skips null and undefined props', () => {
- expect(xdsClassName('button', {variant: 'primary', size: undefined})).toBe(
- 'xds-button primary',
- );
- });
-
- it('works with no props', () => {
- expect(xdsClassName('divider')).toBe('xds-divider');
- });
-
- it('handles string numeric values', () => {
- expect(xdsClassName('heading', {level: '3'})).toBe('xds-heading level-3');
- });
-});
diff --git a/packages/core/src/utils/xdsClassName.ts b/packages/core/src/utils/xdsClassName.ts
deleted file mode 100644
index 65240c0043..0000000000
--- a/packages/core/src/utils/xdsClassName.ts
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (c) Meta Platforms, Inc. and affiliates.
-
-/**
- * Build the xds-* class name string for a component.
- *
- * Every XDS component renders a base class (`xds-button`, `xds-card`, etc.)
- * plus variant classes derived from visual props. These stable class names
- * enable CSS-based theming via @scope'd selectors in defineTheme.
- *
- * <!-- SYNC: packages/cli/src/commands/build-theme.mjs (parseStyleKey + selector generation) -->
- * <!-- SYNC: packages/core/src/utils/parseStyleKey.ts -->
- *
- * Values starting with a digit get prefixed with the prop name since
- * CSS class names can't start with a number (e.g. level=1 → "level-1").
- *
- * @param component - Component name in lowercase (e.g. 'button', 'card')
- * @param props - Visual prop values to include as variant classes
- * @returns Class name string (e.g. "xds-button secondary sm")
- *
- * @example
- * ```ts
- * xdsClassName('button', { variant: 'secondary', size: 'sm' })
- * // → "xds-button secondary sm"
- *
- * xdsClassName('heading', { level: 1 })
- * // → "xds-heading level-1"
- *
- * xdsClassName('card')
- * // → "xds-card"
- * ```
- */
-export function xdsClassName(
- component: string,
- props?: Record<string, string | number | undefined | null>,
-): string {
- const classes = [`xds-${component}`];
-
- if (props) {
- for (const [prop, value] of Object.entries(props)) {
- if (value == null) {
- continue;
- }
- const strValue = String(value);
- // CSS classes can't start with a digit — prefix with prop name
- if (/^\d/.test(strValue)) {
- classes.push(`${prop}-${strValue}`);
- } else {
- classes.push(strValue);
- }
- }
- }
-
- return classes.join(' ');
-}
diff --git a/packages/core/src/utils/xdsThemeProps.test.ts b/packages/core/src/utils/xdsThemeProps.test.ts
new file mode 100644
index 0000000000..dcefccc423
--- /dev/null
+++ b/packages/core/src/utils/xdsThemeProps.test.ts
@@ -0,0 +1,68 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+import {describe, it, expect} from 'vitest';
+import {xdsThemeDataAttributes, xdsThemeProps} from './xdsThemeProps';
+
+describe('xdsThemeProps', () => {
+ it('returns base class for component', () => {
+ expect(xdsThemeProps('card').className).toBe('xds-card');
+ });
+
+ it('adds variant classes', () => {
+ expect(
+ xdsThemeProps('button', {variant: 'secondary', size: 'sm'}).className,
+ ).toBe('xds-button secondary sm');
+ });
+
+ it('prefixes numeric values with prop name', () => {
+ expect(xdsThemeProps('heading', {level: 1}).className).toBe(
+ 'xds-heading level-1',
+ );
+ });
+
+ it('skips null and undefined props', () => {
+ expect(
+ xdsThemeProps('button', {variant: 'primary', size: undefined}).className,
+ ).toBe('xds-button primary');
+ });
+
+ it('works with no props', () => {
+ expect(xdsThemeProps('divider').className).toBe('xds-divider');
+ });
+
+ it('handles string numeric values', () => {
+ expect(xdsThemeProps('heading', {level: '3'}).className).toBe(
+ 'xds-heading level-3',
+ );
+ });
+
+ it('reflects visual props as data attributes', () => {
+ expect(
+ xdsThemeDataAttributes({variant: 'secondary', size: 'sm', level: 2}),
+ ).toEqual({
+ 'data-variant': 'secondary',
+ 'data-size': 'sm',
+ 'data-level': '2',
+ });
+ });
+
+ it('kebab-cases data attribute names', () => {
+ expect(xdsThemeDataAttributes({listStyle: 'ordered'})).toEqual({
+ 'data-list-style': 'ordered',
+ });
+ });
+
+ it('omits nullish data attributes', () => {
+ expect(xdsThemeDataAttributes({variant: 'primary', size: null})).toEqual({
+ 'data-variant': 'primary',
+ });
+ });
+
+ it('returns class and data attributes together', () => {
+ expect(xdsThemeProps('button', {variant: 'primary', size: 'sm'})).toEqual({
+ className: 'xds-button primary sm',
+ 'data-variant': 'primary',
+ 'data-size': 'sm',
+ });
+ });
+});
diff --git a/packages/core/src/utils/xdsThemeProps.ts b/packages/core/src/utils/xdsThemeProps.ts
new file mode 100644
index 0000000000..bb291e43ee
--- /dev/null
+++ b/packages/core/src/utils/xdsThemeProps.ts
@@ -0,0 +1,111 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+export type XDSClassValue = string | number | undefined | null;
+export type XDSClassProps = Record<string, XDSClassValue>;
+export type XDSThemeDataAttributes = Record<
+ `data-${string}`,
+ string | undefined
+>;
+export type XDSThemeProps = {className: string} & XDSThemeDataAttributes;
+
+function toDataAttributeName(prop: string): `data-${string}` {
+ return `data-${prop.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase()}`;
+}
+
+function classTokenForPropValue(prop: string, value: string): string {
+ // CSS classes can't start with a digit — prefix with prop name.
+ return /^\d/.test(value) ? `${prop}-${value}` : value;
+}
+
+/**
+ * Build the legacy xds-* class name string for a component.
+ *
+ * Every XDS component renders a base class (`xds-button`, `xds-card`, etc.)
+ * plus legacy variant classes derived from visual props. XDS also reflects
+ * those visual props as data attributes via `xdsThemeProps()` (`data-variant`,
+ * `data-size`, `data-level`, etc.) so consumers can migrate CSS selectors
+ * away from collision-prone bare class names while old selectors keep working.
+ *
+ * <!-- SYNC: packages/cli/src/commands/build-theme.mjs (parseStyleKey + selector generation) -->
+ * <!-- SYNC: packages/core/src/utils/parseStyleKey.ts -->
+ *
+ * Values starting with a digit get prefixed with the prop name since
+ * CSS class names can't start with a number (e.g. level=1 → "level-1").
+ * Data attributes keep the literal value (e.g. `data-level="1"`).
+ *
+ * @param component - Component name in lowercase (e.g. 'button', 'card')
+ * @param props - Visual prop values to include as legacy variant classes
+ * @returns Class name string (e.g. "xds-button secondary sm")
+ *
+ * @example
+ * ```ts
+ * legacyClassName('button', { variant: 'secondary', size: 'sm' })
+ * // → "xds-button secondary sm"
+ *
+ * legacyClassName('heading', { level: 1 })
+ * // → "xds-heading level-1"
+ *
+ * legacyClassName('card')
+ * // → "xds-card"
+ * ```
+ */
+function legacyClassName(component: string, props?: XDSClassProps): string {
+ const classes = [`xds-${component}`];
+
+ if (props) {
+ for (const [prop, value] of Object.entries(props)) {
+ if (value == null) {
+ continue;
+ }
+ classes.push(classTokenForPropValue(prop, String(value)));
+ }
+ }
+
+ return classes.join(' ');
+}
+
+/**
+ * Reflect XDS visual props as `data-*` attributes.
+ *
+ * Keys are kebab-cased (`listStyle` → `data-list-style`) and values are the
+ * literal prop values, including numeric values (`level: 1` → `data-level="1"`).
+ * Nullish values are omitted.
+ */
+export function xdsThemeDataAttributes(
+ props?: XDSClassProps,
+): XDSThemeDataAttributes {
+ const attrs: XDSThemeDataAttributes = {};
+
+ if (props) {
+ for (const [prop, value] of Object.entries(props)) {
+ if (value == null) {
+ continue;
+ }
+ attrs[toDataAttributeName(prop)] = String(value);
+ }
+ }
+
+ return attrs;
+}
+
+/**
+ * Build the props object components should spread onto the same element that
+ * receives the stable XDS class name.
+ *
+ * This dual-emits the legacy bare classes and the new data-attribute reflection
+ * surface. For example:
+ *
+ * ```ts
+ * xdsThemeProps('button', { variant: 'primary', size: 'sm' })
+ * // → { className: 'xds-button primary sm', data-variant: 'primary', data-size: 'sm' }
+ * ```
+ */
+export function xdsThemeProps(
+ component: string,
+ props?: XDSClassProps,
+): XDSThemeProps {
+ return {
+ className: legacyClassName(component, props),
+ ...xdsThemeDataAttributes(props),
+ };
+}
diff --git a/packages/lab/src/ChatReasoning/XDSChatReasoning.tsx b/packages/lab/src/ChatReasoning/XDSChatReasoning.tsx
index 9e0cf2c945..c9bb13bafa 100644
--- a/packages/lab/src/ChatReasoning/XDSChatReasoning.tsx
+++ b/packages/lab/src/ChatReasoning/XDSChatReasoning.tsx
@@ -27,7 +27,8 @@ import {
durationVars,
easeVars,
} from '@xds/core/theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '@xds/core/utils';
+import {mergeProps} from '@xds/core/utils';
+import {xdsThemeProps} from '../../../core/src/utils/xdsThemeProps';
// =============================================================================
// Types
@@ -258,7 +259,7 @@ export function XDSChatReasoning(props: XDSChatReasoningProps) {
return (
<div
{...mergeProps(
- xdsClassName('chat-reasoning', {
+ xdsThemeProps('chat-reasoning', {
expanded: isExpanded ? 'expanded' : null,
streaming: isStreaming ? 'streaming' : null,
}),
diff --git a/packages/lab/src/CircularProgress/XDSCircularProgress.tsx b/packages/lab/src/CircularProgress/XDSCircularProgress.tsx
index 507842d3a6..fead209248 100644
--- a/packages/lab/src/CircularProgress/XDSCircularProgress.tsx
+++ b/packages/lab/src/CircularProgress/XDSCircularProgress.tsx
@@ -27,8 +27,9 @@ import {
spacingVars,
typeScaleVars,
} from '@xds/core/theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '@xds/core/utils';
+import {mergeProps} from '@xds/core/utils';
import type {XDSBaseProps} from '@xds/core';
+import {xdsThemeProps} from '../../../core/src/utils/xdsThemeProps';
/**
* Extensible variant map for XDSCircularProgress.
@@ -298,7 +299,7 @@ export function XDSCircularProgress({
<div
ref={ref}
{...mergeProps(
- xdsClassName('circular-progress', {variant, size}),
+ xdsThemeProps('circular-progress', {variant, size}),
stylex.props(styles.root, showLabel && styles.rootWithLabel, xstyle),
className,
style,
@@ -326,7 +327,7 @@ export function XDSCircularProgress({
)}>
<circle
{...mergeProps(
- xdsClassName('circular-progress-track'),
+ xdsThemeProps('circular-progress-track'),
stylex.props(styles.track, trackVariantStyles[variant]),
)}
cx={center}
@@ -337,7 +338,7 @@ export function XDSCircularProgress({
{isIndeterminate ? (
<circle
{...mergeProps(
- xdsClassName('circular-progress-fill', {variant}),
+ xdsThemeProps('circular-progress-fill', {variant}),
stylex.props(styles.fillIndeterminate, variantStyles[variant]),
)}
cx={center}
@@ -348,7 +349,7 @@ export function XDSCircularProgress({
) : (
<circle
{...mergeProps(
- xdsClassName('circular-progress-fill', {variant}),
+ xdsThemeProps('circular-progress-fill', {variant}),
stylex.props(styles.fill, variantStyles[variant]),
)}
cx={center}
diff --git a/packages/lab/src/CodeEditor/XDSCodeEditor.tsx b/packages/lab/src/CodeEditor/XDSCodeEditor.tsx
index 26c7f410b3..72755decd7 100644
--- a/packages/lab/src/CodeEditor/XDSCodeEditor.tsx
+++ b/packages/lab/src/CodeEditor/XDSCodeEditor.tsx
@@ -26,13 +26,14 @@ import {
typeScaleVars,
borderVars,
} from '@xds/core/theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '@xds/core/utils';
+import {mergeProps} from '@xds/core/utils';
import {
tokenize,
tokenizeAsync,
SYNC_TOKENIZE_THRESHOLD,
} from '@xds/core/CodeBlock';
import type {TokenLine} from '@xds/core/CodeBlock';
+import {xdsThemeProps} from '../../../core/src/utils/xdsThemeProps';
import {
ensureHighlightStyles,
applyHighlightRangesFlat,
@@ -416,7 +417,7 @@ export function XDSCodeEditor({
<div
ref={ref}
{...mergeProps(
- xdsClassName('codeeditor', {size, language}),
+ xdsThemeProps('codeeditor', {size, language}),
stylex.props(styles.root, focused && styles.rootFocused, xstyle),
className,
style,
diff --git a/packages/lab/src/SVGIcon/XDSSVGIcon.tsx b/packages/lab/src/SVGIcon/XDSSVGIcon.tsx
index c8269b391b..31ea6ab306 100644
--- a/packages/lab/src/SVGIcon/XDSSVGIcon.tsx
+++ b/packages/lab/src/SVGIcon/XDSSVGIcon.tsx
@@ -22,9 +22,10 @@
import {type CSSProperties, type SVGProps, useId} from 'react';
import * as stylex from '@stylexjs/stylex';
import {colorVars} from '@xds/core/theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '@xds/core/utils';
+import {mergeProps} from '@xds/core/utils';
import {iconVars} from './tokens.stylex';
import {variations, opticalSize} from './variations.stylex';
+import {xdsThemeProps} from '../../../core/src/utils/xdsThemeProps';
// =============================================================================
// Types
@@ -367,7 +368,7 @@ export function XDSSVGIcon({
viewBox={viewBox}
aria-hidden="true"
{...mergeProps(
- xdsClassName('svg-icon', {variation, size, color}),
+ xdsThemeProps('svg-icon', {variation, size, color}),
stylex.props(
styles.root,
colorStyles[color],
diff --git a/packages/lab/src/Schedule/XDSSchedule.tsx b/packages/lab/src/Schedule/XDSSchedule.tsx
index dca4043758..c042ee1dc5 100644
--- a/packages/lab/src/Schedule/XDSSchedule.tsx
+++ b/packages/lab/src/Schedule/XDSSchedule.tsx
@@ -17,12 +17,13 @@
import {Suspense, useCallback, useMemo, useState} from 'react';
import * as stylex from '@stylexjs/stylex';
import type {XDSBaseProps} from '@xds/core';
-import {xdsClassName, mergeProps, plainDateFromInstant} from '@xds/core/utils';
+import {mergeProps, plainDateFromInstant} from '@xds/core/utils';
import {eventOverlapsRange, getBrowserTimezoneID, sortEvents} from './dateMath';
import {XDSScheduleContext} from './context';
import {defaultXDSSchedulePlugins} from './plugins';
import {styles} from './shared';
import {createZonedDateTime} from './zonedDateTime';
+import {xdsThemeProps} from '../../../core/src/utils/xdsThemeProps';
import type {
CalendarEvent,
Instant,
@@ -264,7 +265,7 @@ export function XDSSchedule({
<div
{...rest}
{...mergeProps(
- xdsClassName('schedule'),
+ xdsThemeProps('schedule'),
stylex.props(styles.root, xstyle),
className,
style,
diff --git a/packages/lab/src/Stepper/XDSStep.tsx b/packages/lab/src/Stepper/XDSStep.tsx
index f846877b60..3e6e4670a4 100644
--- a/packages/lab/src/Stepper/XDSStep.tsx
+++ b/packages/lab/src/Stepper/XDSStep.tsx
@@ -28,10 +28,11 @@ import {
durationVars,
easeVars,
} from '@xds/core/theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '@xds/core/utils';
+import {mergeProps} from '@xds/core/utils';
import {XDSIcon} from '@xds/core/Icon';
import type {XDSBaseProps} from '@xds/core';
import {useXDSStepperContext} from './XDSStepperContext';
+import {xdsThemeProps} from '../../../core/src/utils/xdsThemeProps';
export interface XDSStepProps extends XDSBaseProps<HTMLDivElement> {
/** Ref forwarded to the root element */
@@ -366,7 +367,7 @@ export function XDSStep({
onClick={handleClick}
aria-label={`Go to step ${step + 1}: ${label}`}
{...mergeProps(
- xdsClassName('step-indicator', {state: stepState}),
+ xdsThemeProps('step-indicator', {state: stepState}),
stylex.props(
styles.buttonReset,
styles.indicator,
@@ -380,7 +381,7 @@ export function XDSStep({
<div
aria-hidden="true"
{...mergeProps(
- xdsClassName('step-indicator', {state: stepState}),
+ xdsThemeProps('step-indicator', {state: stepState}),
stylex.props(styles.indicator, indicatorVariantStyle),
)}>
{indicatorContent}
@@ -424,7 +425,7 @@ export function XDSStep({
<div
ref={ref}
{...mergeProps(
- xdsClassName('step', {state: stepState}),
+ xdsThemeProps('step', {state: stepState}),
stylex.props(styles.verticalRoot, xstyle),
className,
style,
@@ -438,7 +439,7 @@ export function XDSStep({
<div {...stylex.props(styles.verticalConnector)}>
<div
{...mergeProps(
- xdsClassName('step-connector'),
+ xdsThemeProps('step-connector'),
stylex.props(
styles.verticalConnectorLine,
isCompleted
@@ -463,7 +464,7 @@ export function XDSStep({
<div
ref={ref}
{...mergeProps(
- xdsClassName('step', {state: stepState}),
+ xdsThemeProps('step', {state: stepState}),
stylex.props(styles.horizontalRoot, xstyle),
className,
style,
@@ -479,7 +480,7 @@ export function XDSStep({
<div {...stylex.props(styles.horizontalConnector)}>
<div
{...mergeProps(
- xdsClassName('step-connector'),
+ xdsThemeProps('step-connector'),
stylex.props(
styles.horizontalConnectorLine,
isCompleted
diff --git a/packages/lab/src/Stepper/XDSStepper.tsx b/packages/lab/src/Stepper/XDSStepper.tsx
index 55e40668bd..451430a679 100644
--- a/packages/lab/src/Stepper/XDSStepper.tsx
+++ b/packages/lab/src/Stepper/XDSStepper.tsx
@@ -19,8 +19,9 @@
import {useMemo, type ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
-import {xdsClassName, mergeProps} from '@xds/core/utils';
+import {mergeProps} from '@xds/core/utils';
import type {XDSBaseProps} from '@xds/core';
+import {xdsThemeProps} from '../../../core/src/utils/xdsThemeProps';
import {
XDSStepperContext,
type XDSStepperOrientation,
@@ -116,7 +117,7 @@ export function XDSStepper({
<nav ref={ref} aria-label={label} {...rest}>
<ol
{...mergeProps(
- xdsClassName('stepper', {orientation}),
+ xdsThemeProps('stepper', {orientation}),
stylex.props(
styles.root,
orientation === 'horizontal'
diff --git a/packages/themes/default/src/defaultTheme.ts b/packages/themes/default/src/defaultTheme.ts
index 206724f958..da366ef4c6 100644
--- a/packages/themes/default/src/defaultTheme.ts
+++ b/packages/themes/default/src/defaultTheme.ts
@@ -8,7 +8,9 @@
*
* Typography sizing is driven by typography.scale, which auto-generates both
* the token values (--text-heading-1-size, --text-body-size, etc.) and the
- * component override rules (.xds-heading.level-1 { font-size: ... }).
+ * component override rules (currently legacy class selectors such as
+ * .xds-heading.level-1 { font-size: ... }; components also emit matching
+ * data-level/data-type attributes for the selector migration).
*
* Only non-typography component overrides need to be specified manually.
*/