-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add support for important
in v4
#14448
Conversation
f8780bf
to
ca56bde
Compare
6ffec7e
to
ed8a056
Compare
a33fd23
to
f06bb16
Compare
e59d8a9
to
1971422
Compare
4b91d22
to
f27d403
Compare
75f505f
to
3871ea1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all seems easy enough, just one question inline. Happy to stamp it but I feel like this could benefit from someone else's 👀 too!
Recording decisions from our call:
|
@thecrypticace & @RobinMalfait – I'm surprised you decided to keep supporting this "selector prefix" API in v4, given that no amount of specificity can make a rule in a cascade layer "escape" its layer, i.e. no utility in |
@benface Yeah so we ended up doing it only for backwards compatibility purposes to hopefully be less breaking for the projects that are still using this feature. Ideally though users would switch entirely to relying on cascade layers and remove this from their projects. |
Well, they have to, as there's no way in Tailwind 4 to render utilities outside the |
You definitely can. You just have to inline the imports. We rely on CSS's native layer features including
To keep the layers you do this (this is almost exactly what is in
|
This PR allows modifying utility output by wrapping all utility declarations in a custom selector or marking all utility declarations as
!important
. This is the v4 equivalent to theimportant
option in thetailwind.config.js
file.Mark all utility declarations as
!important
To add
!important
to all utility declarations, you add animportant
flag after the@import
statement fortailwindcss
ortailwindcss/utilities
:Example utility output:
This is equivalent to adding
important: true
to thetailwind.config.js
file — which is still supported for backwards compatibility.Wrap all utility declarations in a custom selector
For backwards compatibility, if you need to nest all utilities in an
#app
selector you addimportant: "#app"
to your config file:This does not bring back support for the
respectImportant
flag inaddUtilities
/matchUtilities
.