Comments (1)
Hey! So the behavior you're seeing is partially due to backwards compatability with configs from Tailwind v2. In v2, before the JIT, you could specify the negative version of a utility by prefixing the value with a -
. And the convention is that the class name for the negative version of a utility starts with a -
character. So you could have a value of spacing.-3
and it would generate a class of -m-3
. In v3, we generate the negative version of supported utilities automatically but preserved the ability to specify the negative version of a utility in the config for backwards compatibility purposes. The way this works is on a more global level so even though a "negative" color utility doesn't really make sense we still allow users to generate it — again for backwards compatability purposes.
In v4, none of this is an issue and the class you've written is actually possible with the following theme config:
@theme {
--colors--bg-primary: #f00;
}
In general in v4 negative utilities:
- Are supported on a per-plugin basis (meaing
-bg-bg-primary
will never exist) - Are always generated with the
calc({value} * -1)
syntax automatically - Don't have a way to specify sepearate values for negative utilities in the theme thus side stepping potential confusion when a negative utility has a different, unrelated value than the positive one (usually because of typos).
- Has CSS variables as a first-class citizen so such theme definitions are often less necessary because we generate utility definitions that use CSS variables.
The fact that Tailwind v3 generates anything for the class bg--bg-primary
is a bit of a longstanding bug. But it's not that it generates with the wrong class name. It's that it shouldn't generate any CSS at all. Given that we're all in on v4 right now i'm not sure if this will be fixed in a v3.x.x release but if it is it'll be fixed as to not generate CSS.
from tailwindcss.
Related Issues (20)
- bg-opacity doesn't work on dark mode
- ```content.transform``` doesn't work in next.js HOT 1
- [Prettier Plugin] Handle two more plugins HOT 3
- not working in docker HOT 3
- other postcss plugins do not work with tailwindcss HOT 1
- `<alpha-value>` is not recognized on reuse HOT 2
- Vulnerable Dependency - micromatch HOT 3
- v4: tailwind.default is not a function when running with Angular 17 and esbuild
- Classes generation error using symlink HOT 1
- [v3] Double quotes break arbitrary variants HOT 2
- `dark:` does not work with `@apply` in v3.4.3
- Create plugin: addBase does not work inside of matchComponents
- Col-end does not support negative values HOT 2
- For example: min-[1620px] is not workin, tailwind dont see this, but media xl, 2xl, md he is see)) (sorry for my english)
- Tailwind Play and Play CDN don't work with some custom utilities HOT 3
- Classes are prefixed when using `has-*` variants with arbitrary values HOT 2
- Unable to set default light mode in Vercel portfolio template HOT 2
- Unable to add borderRadius in tailwind.config.js. Inside theme.extend property HOT 1
- Class detection in Ruby Template files
- Small bug on negative 0.5 classes (like "-left-0.5") HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tailwindcss.