Skip to content

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

TypeScript

feat(theme): add --color-track + Spinner consumes it for fully tokenized track (#2170)

rubyycheung141303e3f5de
diff --git a/packages/cli/docs/tokens.doc.mjs b/packages/cli/docs/tokens.doc.mjs
index 600d473799..6844ff6d35 100644
--- a/packages/cli/docs/tokens.doc.mjs
+++ b/packages/cli/docs/tokens.doc.mjs
@@ -1,7 +1,7 @@
// AUTO-GENERATED — do not edit manually.
// Source: packages/core/src/theme/tokens.stylex.ts
// Run: node scripts/generate-token-docs.mjs
-// Total: 182 tokens across 12 categories.
+// Total: 183 tokens across 12 categories.
/** @type {import('../../core/src/docs-types').ReferenceDoc} */
@@ -206,6 +206,11 @@ export const docs = {
"#CCD3DB",
"#5A5E66"
],
+ [
+ "--color-track",
+ "#CCD3DB",
+ "#5A5E66"
+ ],
[
"--color-shadow",
"light-dark(rgba(5, 54, 89, 0.1), rgba(0, 0, 0, 0.3))",
diff --git a/packages/core/src/Spinner/XDSSpinner.tsx b/packages/core/src/Spinner/XDSSpinner.tsx
index 339646ec76..bc2b273f13 100644
--- a/packages/core/src/Spinner/XDSSpinner.tsx
+++ b/packages/core/src/Spinner/XDSSpinner.tsx
@@ -16,7 +16,7 @@
import {useEffect, useRef, type ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
-import {colorVars, durationVars, spacingVars} from '../theme/tokens.stylex';
+import {durationVars, spacingVars} from '../theme/tokens.stylex';
import {useXDSTheme} from '../theme/useXDSTheme';
import {XDSBaseProps} from '../XDSBaseProps';
import {XDSText} from '../Text/XDSText';
@@ -162,15 +162,23 @@ export function XDSSpinner({
const {border, diameter} = SIZES[size];
const pixelRatio = window.devicePixelRatio || 1;
- // Resolve colors from theme tokens (useXDSTheme handles light/dark resolution)
+ // Resolve colors from theme tokens (useXDSTheme handles light/dark resolution).
+ // - default → accent ring on a track tuned to body luminance
+ // - subtle → secondary text color, less prominent
+ // - onMedia → on-dark color, with a translucent track for photos/video
const activeColor =
shade === 'onMedia'
- ? themeTokens['--color-on-dark'] || '#FFFFFF'
+ ? themeTokens['--color-on-dark']
: shade === 'subtle'
- ? themeTokens['--color-text-secondary'] || '#65676B'
- : themeTokens['--color-accent'] || '#0064E0';
+ ? themeTokens['--color-text-secondary']
+ : themeTokens['--color-accent'];
+ // Track derives from --color-on-dark for onMedia (with a 30% alpha so the
+ // ring reads against arbitrary backgrounds) and from --color-track for the
+ // body-luminance shades. Both branches are fully theme-driven.
const backgroundColor =
- shade === 'onMedia' ? 'rgba(255, 255, 255, 0.3)' : 'rgba(0, 0, 0, 0.08)';
+ shade === 'onMedia'
+ ? `${themeTokens['--color-on-dark']}4D`
+ : themeTokens['--color-track'];
const radius = (diameter / 2) * pixelRatio;
const lineWidth = border * pixelRatio;
diff --git a/packages/core/src/tailwind-theme.css b/packages/core/src/tailwind-theme.css
index 0b2e4b8651..f5f87b1b20 100644
--- a/packages/core/src/tailwind-theme.css
+++ b/packages/core/src/tailwind-theme.css
@@ -85,6 +85,7 @@
--color-on-dark: var(--color-on-dark);
--color-on-light: var(--color-on-light);
--color-skeleton: var(--color-skeleton);
+ --color-track: var(--color-track);
--color-shadow: var(--color-shadow);
/* --- Hue palette ---
diff --git a/packages/core/src/theme/expandColorScale.test.ts b/packages/core/src/theme/expandColorScale.test.ts
index ed8450568b..7fad9d35d4 100644
--- a/packages/core/src/theme/expandColorScale.test.ts
+++ b/packages/core/src/theme/expandColorScale.test.ts
@@ -30,6 +30,7 @@ describe('expandColorScale', () => {
'--color-border',
'--color-border-emphasized',
'--color-skeleton',
+ '--color-track',
'--color-shadow',
'--color-tint-hover',
];
diff --git a/packages/core/src/theme/expandColorScale.ts b/packages/core/src/theme/expandColorScale.ts
index ae2d87aa30..9053a635e6 100644
--- a/packages/core/src/theme/expandColorScale.ts
+++ b/packages/core/src/theme/expandColorScale.ts
@@ -166,6 +166,9 @@ export function expandColorScale(
// Effects
'--color-skeleton': ld(NV[70], NV[30]),
+ // Channel-on-body surface (ProgressBar/Slider tracks, Switch off-state).
+ // Defaults to the same NV[70]/NV[30] ramp stop as --color-skeleton.
+ '--color-track': ld(NV[70], NV[30]),
'--color-shadow': ld(hexWithAlpha(N[0], 0.1), hexWithAlpha(N[0], 0.3)),
'--color-tint-hover': ld('black', 'white'),
};
diff --git a/packages/core/src/theme/tokens.stylex.ts b/packages/core/src/theme/tokens.stylex.ts
index def3c086a9..4452b5bdae 100644
--- a/packages/core/src/theme/tokens.stylex.ts
+++ b/packages/core/src/theme/tokens.stylex.ts
@@ -69,6 +69,11 @@ export const colorDefaults = {
// Effects
'--color-skeleton': 'light-dark(#CCD3DB, #5A5E66)',
+ // "Channel on body" — slim affordances that need to read against body
+ // luminance (ProgressBar tracks, Slider rails, Switch off-state). Default
+ // is the same low-contrast surface as --color-skeleton; themes can
+ // override per their neutral ramp if 1-D channels need more weight.
+ '--color-track': 'light-dark(#CCD3DB, #5A5E66)',
'--color-shadow': 'light-dark(rgba(5, 54, 89, 0.1), rgba(0, 0, 0, 0.3))',
// Hover tint: black in light mode, white in dark mode - used with color-mix for hover states
'--color-tint-hover': 'light-dark(black, white)',