diff --git a/apps/web/src/lib/themes.ts b/apps/web/src/lib/themes.ts index 6ba4bb7792..08208a191e 100644 --- a/apps/web/src/lib/themes.ts +++ b/apps/web/src/lib/themes.ts @@ -164,7 +164,9 @@ const STYLE_ELEMENT_ID = "t3code-theme-tokens"; function buildCssBlock(selector: string, tokens: ThemeTokenMap): string { const entries = Object.entries(tokens) as [ThemeToken, string][]; if (entries.length === 0) return ""; - const declarations = entries.map(([token, value]) => ` --color-${token}: ${value};`).join("\n"); + // Override the intermediate CSS variables (--primary, --ring, etc.) + // which feed into Tailwind's --color-* via @theme inline { --color-primary: var(--primary) }. + const declarations = entries.map(([token, value]) => ` --${token}: ${value};`).join("\n"); return `${selector} {\n${declarations}\n}`; } diff --git a/apps/web/src/routes/__root.tsx b/apps/web/src/routes/__root.tsx index 92ab8adf55..4a7778409c 100644 --- a/apps/web/src/routes/__root.tsx +++ b/apps/web/src/routes/__root.tsx @@ -39,6 +39,11 @@ export const Route = createRootRouteWithContext<{ }); function RootRouteView() { + // Mount appearance system — drives .dark class, theme tokens, and Electron sync. + // Must be called before any early returns to satisfy React's Rules of Hooks. + // The import also triggers module-scope FOUC prevention. + useAppearance(); + if (!readNativeApi()) { return (