Skip to content

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

TypeScript

Fix built theme.css pinning color-scheme so Theme mode can force light/dark (#3690)

prajwal raut47fd18479579
diff --git a/packages/cli/src/commands/build-theme.mjs b/packages/cli/src/commands/build-theme.mjs
index c7c1d149fb..828134ad4a 100644
--- a/packages/cli/src/commands/build-theme.mjs
+++ b/packages/cli/src/commands/build-theme.mjs
@@ -939,15 +939,9 @@ export function registerTheme(program) {
if (component.length > 0) {
const componentInner = component.join('\n\n');
const componentScope = `@scope (${scopeSelector}) to (${scopeTo}) {\n${componentInner}\n}`;
- // light-dark() needs a color-scheme declaration in this bundle, but a
- // bare `:root { color-scheme: light dark }` outranks reset.css's
- // `html[data-theme]` mapping (astryx-theme layer comes after reset),
- // silently defeating `<Theme mode>` forcing on <html>. Mirror the
- // attribute-keyed mapping so the declaration follows the active mode.
+ // #3658: also emit attribute-specific rules so <Theme mode> can override color-scheme
const colorSchemeDecl = componentScope.includes('light-dark(')
- ? ' :root { color-scheme: light dark; }\n' +
- ' html[data-theme="light"] { color-scheme: light; }\n' +
- ' html[data-theme="dark"] { color-scheme: dark; }\n\n'
+ ? ' :root { color-scheme: light dark; }\n html[data-theme="light"] { color-scheme: light; }\n html[data-theme="dark"] { color-scheme: dark; }\n\n'
: '';
cssParts.push(
`@layer astryx-theme {\n${colorSchemeDecl}${componentScope}\n}`,