-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Add support for prefixes #14501
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 prefixes #14501
Conversation
5401593 to
4cd8e7e
Compare
|
@RobinMalfait Should we switch to the new prefix syntax (where it is actually a prefix lol) in this PR and do the codemod later — or land the old prefix version and then switch to the new one when we land the codemod? |
|
@thecrypticace since we didn't have prefix support before this in v4, I would say use the new syntax only and introduce a codemod later (@philipp-spiess is already making good progress on the infra for that). Don't think it's worth / necessary to ship support for the old prefix. Because, if we have a codemod, then we would remove support for the old prefix again which makes it a breaking change (it's still alpha so it's fine, but still.) |
6ffec7e to
ed8a056
Compare
|
a33fd23 to
f06bb16
Compare
philipp-spiess
left a comment
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.
Looks good to me overall! One question that could need some clarification is what should the theme() function do when it does get a prefix fed into it, see the inline comment on the new test.
Co-authored-by: Philipp Spiess <[email protected]>
4b91d22 to
f27d403
Compare
RobinMalfait
left a comment
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.
A bit annoying to configure, but I do like the new syntax for it. Can't wait for writing a codemod for this 😅
This PR adds support for requiring a custom prefix on utility classes.
Prefixes work a bit differently in v4 than they did in v3:
tw:bg-whitetw:hover:bg-whitetw:[color:red]--tw-color-white: #fff;#tw#or__or similar prefixes are allowedTo configure a prefix you can use add
prefix(tw)to your theme or when importing Tailwind CSS like so:This will configure Tailwind CSS to require a prefix on all utility classes when used in HTML:
and when used in CSS via
@apply:Additionally, the prefix will be added to the generated CSS variables. You do not need to prefix the variables in the
@themeblock yourself — Tailwind CSS handles this automatically.A prefix is not necessary when using the
theme(…)function in your CSS or JS given that plugins will not know what the current prefix is and must work with or without a prefix:However, because the variables themselves are prefixed when outputting the CSS, you do need to prefix the variables when using
var(…)in your CSS:If you want to customize the prefix itself change
twto something else: