Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Theme class name inconsistency with Tailwind #264

Open
call-a3 opened this issue Dec 12, 2024 · 3 comments
Open

Theme class name inconsistency with Tailwind #264

call-a3 opened this issue Dec 12, 2024 · 3 comments
Labels

Comments

@call-a3
Copy link

call-a3 commented Dec 12, 2024

Expected Behavior

The Tailwind component detects and renders the css for all classNames used in its children, even when those are abstracted into separate React Components.

Actual Behavior

The Tailwind component seems to only detect classNames used in its direct children.

Additional Information

I believe this bug report/feature request is a duplicate of #73, albeit simpler since there was also a React hook involved there. I hope by adding a reproduction case this time, we will have more success in helping us find a solution.

@call-a3
Copy link
Author

call-a3 commented Dec 12, 2024

Update: some further experimentation on my end revealed that the problem wasn't with the Tailwind component itself, but probably due to a small incompatibility between tailwind itself and UnoCSS.

My tailwind config had a color declaration like this in the reproduction:

const theme = {
  colors: {
    "primary-accent": { DEFAULT: "#850c0c", contrast: "#fff" },
  },
};

It works when I replace that with.

const theme = {
  colors: {
    primaryAccent: { DEFAULT: "#850c0c", contrast: "#fff" },
  },
};

If I want to use a classname like "text-primary-accent", tailwind expects me to use the former syntax (it doesn't automatically turn the classname into kebab-case), the later would result in me having to use "text-primaryAccent".

Perhaps it might be good to put a disclaimer in the documentation that UnoCSS might need a slightly different configuration for the same functionality as plain Tailwind?

I'm also thinking I might create an upstream bug in UnoCSS if Tailwind compatibility is something they claim to support out of the box, but I'm not sure about that (haven't spotted it from a quick glance at their website). Any insights from anyone here?

@shellscape
Copy link
Owner

Thanks for reporting this and the additional triage.

I'm also thinking I might create an upstream bug in UnoCSS if Tailwind compatibility is something they claim to support out of the box, but I'm not sure about that (haven't spotted it from a quick glance at their website). Any insights from anyone here?

Yes, they have a preset that is supposed to be tailwind compatible. Here's a direct link to that preset: https://github.com/unocss/unocss/tree/main/packages/preset-wind

We'll leave this open here, but it definitely looks like an upstream bug in unocss. They're pretty good about addressing bugs like these quickly, and I would encourage you to open an issue there as well.

@shellscape
Copy link
Owner

In the meantime I'm going to update us to the new v0.65.0 version that was released last week.

@shellscape shellscape changed the title Tailwind does not render classes from indirectly/nested children Theme class name inconsistency with Tailwind Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants