TailwindCSS v4 does not recognize some colors #18693
Unanswered
androide-osorio
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description
Hello,
At my company, we use TailwindCSS to build and maintain the component libraries that make our design system. We are currently migrating our Tailwind 3.4.10 Tailwind 4.1.0, and I have encountered a puzzling issue.
We are generating a custom theme with a prefix, based on the design system's design tokens using style dictionary. We divide colors in primitive and semantic tokens, the latter ones just are a reference to the first ones. The output looks something similar to this:
Expected behavior
Expected class names like
uy:bg-grayscale-L1, uy:bg-grayscale-L2, ... uy:bg-surface-neutral
to be generated and to apply the styles.Actual behavior
The classes for the primitive tokens are not generated, but the classes for the semantic tokens do get generated.
In the screenshot above, that element should be almost black. The other elements beside it render colors correctly because they use the semantic classes (tokens that are aliases of the of colors in the color palette)
What I find most puzzling is that, when I add the theme into Tailwind Play, everything works correctly: https://play.tailwindcss.com/3BGP0eYX8t, which means it is not a theme configuration issue.
Environment setup
The project is an Nx Monorepo, containing the component library, in this fashion:
<root> |_ packages |_ design-system |_ components // consumes the theme css file |_ themes // exports the theme css file
the
themes
package exports the generated css file as its default export:The component project itself uses Vite for bundling the library and Storybook as the testing platform.
And in
.storybook
folder, we just have a stylesheet that imports the theme css file:Package versions
These are the (abbreviated) package dependencies.
any help you can provide would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions