Tailwind CSS 4 theme tokens in Next.js 16: four silent bugs that builds don't catch
A developer migrated a landing page's colors to Tailwind CSS 4 theme tokens, using oklch values and semantic surface and ink tokens that change in dark mode. Although every build passed, computed-style checks in Chromium revealed four bugs that the build process never reported. The tests ran on a fresh Next.js 16.5.0 project with React 19.3.1 and Tailwind CSS 4.3.5, and the setup no longer uses a postcss.config.mjs file. The core issue was that semantic tokens referencing other variables resolved on :root, so dark mode overrides were ignored, and the fix was to use @theme inline. The article continues with further pitfalls, including how @theme placed inside a media query applies globally.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in