Replies: 4 comments
-
As a workaround, you could consider prefixing your variable so that it doesn't start with the |
Beta Was this translation helpful? Give feedback.
-
Yes, but as a workaround. The main point here is to stay consistent, because if I later need to use this directly in CSS, I know the class name is Honestly, all of this could have been avoided if we had a native solution for using Also, if we want to completely switch to native CSS, what is the purpose of Sorry, I know this is a topic for another discussion, but I think if I could use Now I have to write full CSS and use |
Beta Was this translation helpful? Give feedback.
-
Hey! To me this is all expected behavior — anything you declare under If you want to define a variable called https://play.tailwindcss.com/qtWUiET5Ww?file=css ![]() I'm not sure what you mean about Stuff like |
Beta Was this translation helpful? Give feedback.
-
Thanks for taking the time to respond and help, I appreciate it!
Ah, I see, I didn't know about this
Honestly, I haven't tried this at all. This is what I need, thanks a lot for the advice, this fixes the issue! I was of the opinion that all variables related to configuration or theme should be written inside Regarding @utility font-400 {
font-variation-settings: 'wght' 400;
} and later use it like this: p {
@apply font-400;
} So I wouldn't need any additional custom variables at all. Right now this works fine, but there are many cases where people say that it is not recommended to use the I think this all started when you officially tweeted that This is a big win for writing custom CSS quickly, no need to even think about what the real name of a CSS property is or anything like that, just apply the class name and that's it. Right now I have to write full stylings and think about the real CSS which slows me down a lot. Also, when i need to write transitions with custom css, using apply is easy: p {
@apply transition-colors;
} This becomes difficult to reproduce with native css.
I know, but this could have been written simply like this: p {
margin-top: calc(var(--spacing) * 4);
} or <div class="pt-[calc(var(--spacing)*4)]"></div> It's a nice addition and all, but if we can use some functions and other non-native directives, why are people so against |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I just bumped into an issue where having a custom CSS variable defined in
@theme
with the same name as a customtw
@utility
causes duplicate classes to be generated, with incorrect properties. This breaks the CSS and results in styles not rendering properly on the page.I'm using the latest version of
tailwind
in asveltekit
project with the default configuration. I also tested this in the officialtw
playground and I see the same behavior. Screenshots are attached so you can immediately see that something's wrong.Playground link
I spent more than half an hour trying to find the problem. After renaming the custom variable, everything worked fine again. I believe this should be addressed, since CSS variables
--custom-name
andtw
utilities.custom-name
are diffirent concepts and shouldn't interfere with each other.I'm running into this because I want to define a custom utils and vars for variable font in the
@theme
config:So I can use it later with custom util:
or via custom css directly if needed:
These variable names should remain isolated, custom properties under
@theme
shouldn’t conflict with custom@utilities
.In short: everything works as expected unless a custom
@theme
variable shares its name with a custom@utility
, in that case, CSS breaks due to conflicting class generation.Beta Was this translation helpful? Give feedback.
All reactions