-
Notifications
You must be signed in to change notification settings - Fork 515
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
Using primary
/ gray
as main colors might conflict with existing projects.
#1721
Comments
I found the configuration Turns out, you can not use
And then you are free to use |
The goal of this feature is to be able to change your colors dynamically through your If you name a color primary or gray the module will erase it as we need the CSS variables. I hear it might be a conflict in some projects but we're too committed to this naming to change it in my opinion. Even in the next major (v3), I don't plan to change this. |
Thanks for the explanation! What would actually be detrimental from your side, if you used From a workload-perspective, the change should be done pretty quickly using search and replace. Imho this is a problem as old as CSS. It has been a long-time best practice for packages to have a specific prefix with their classes to not get into conflict with existing classes from the main project or other packages. Only now Tailwind is in the middle - but the problem is still the same. What if other packages decide to also define their own |
I personally get the point, and don't really mind. However, I think the fact that I struggled for around one hour as to why tailwind purges out my own primary and gray color set, I thought the most obvious way to have a config that would be readable, would be to use primary and gray in my tailwind config and then declare those as the colors for Nuxt UI:
So If you don't intend in changing that in any way, I'd propose to use a more visible Alert for this on the theming page of the docs. |
I just spent a few days scratching my head on this one, then a few hours experimenting on a large, mature project to try and get to the bottom of this! It took a lot of detective work to finally work out why introducing @benjamincanac – two options which could get round this; for any existing
|
So to summarize, we could solve this issue by adding a warning if we detect a |
It would point developers to the problem, but imho not solve the underlying problem. Solving the problem in an affected project would require some manual refactoring, which can amount to many man-hours, probably turning off devs from using
|
I'm actually about to submit a PR for this now. It reuses any configured colors so should be a transparent fix, and would not require prefixing. This might also fix the issue of "reserved" colors; @benjamincanac I'll push a WIP, then I'll see if we need any docs updates. |
Interestingly, we've been caught out by a related problem in our project, in that we want to use However, I think I have a solution, but I'll need to test it, then PR it. |
Description
primary
,secondary
, etc. is a rather popular naming scheme for tailwind-color-classes in many projects. This leads to problems when trying to addnuxt/ui
to such a project, since it defines and usesprimary
itself. The same problem could arise withgray
.I would suggest renaming the classes to e.g.
ui-primary
, or make the class-name configurable.Additional context
No response
The text was updated successfully, but these errors were encountered: