packages/eclipse/TROUBLESHOOTING.md
Colors defined in the design system were not appearing in the browser when running the dev server on localhost:3001 or localhost:3002.
The issue was caused by incorrect syntax for Tailwind CSS v4. The project was using Tailwind CSS v4 syntax in postcss.config.mjs but the CSS custom properties were defined using Tailwind v3 patterns.
globals.css to use Tailwind v4 @theme directiveBefore (v3 style):
@layer base {
:root {
--background-default: hsl(0 0% 100%);
--foreground-neutral: hsl(220 25% 9%);
/* ... */
}
.dark {
--background-default: hsl(220 54% 5%);
/* ... */
}
}
After (v4 style):
@theme {
--color-background-default: hsl(0 0% 100%);
--color-foreground-neutral: hsl(220 25% 9%);
/* ... */
}
@theme dark {
--color-background-default: hsl(220 54% 5%);
/* ... */
}
Key Changes:
@theme directive instead of @layer base with :root--color- prefix to all color variables (required by Tailwind v4)@theme dark for dark mode instead of .dark class selector@import "tailwindcss"; at the top of the filetailwind.config.ts to reference correct CSS variablesBefore:
colors: {
background: {
DEFAULT: "var(--background-default)",
neutral: "var(--background-neutral)",
}
}
After:
colors: {
background: {
DEFAULT: "var(--color-background-default)",
neutral: "var(--color-background-neutral)",
}
}
After making these changes, restart the dev server:
cd apps/eclipse/dev
pnpm dev
Colors should now render correctly in the browser.
@theme directive instead of CSS layers--color-@theme dark blockcalc() or other CSS functions directly in @theme@import "tailwindcss"; must be firstClicking the dark mode toggle button doesn't switch between light and dark themes, or the page starts in dark mode when it should start in light mode.
The dark class needs to be applied to the <html> or document root element, not a nested div, for Tailwind's dark mode to work properly with darkMode: "class".
Update the component to apply the dark class to document.documentElement:
Before:
export function ShowcaseExample() {
const [isDark, setIsDark] = React.useState(false);
return (
<div className={isDark ? "dark" : ""}>
<div className="min-h-screen bg-background-default">
</div>
</div>
);
}
After:
export function ShowcaseExample() {
const [isDark, setIsDark] = React.useState(false);
React.useEffect(() => {
if (isDark) {
document.documentElement.classList.add("dark");
} else {
document.documentElement.classList.remove("dark");
}
}, [isDark]);
return (
<div>
<div className="min-h-screen bg-background-default">
</div>
</div>
);
}
darkMode: "class" is set in tailwind.config.ts:root and .dark selectors are used in globals.css (not @theme directives)If port 3001 is already in use, Vite will automatically try the next available port (3002, 3003, etc.). Check the terminal output for the actual port being used.
If you see an error about @tailwindcss/postcss not being found:
pnpm install @tailwindcss/postcss
If you get TypeScript errors about number types in fontWeight, ensure you're converting them to strings:
fontWeight: {
normal: tokens.typography.fontWeight.normal.toString(),
}