Issues with @apply Directive and Prefix Configuration in Tailwind CSS v4 #16221
Unanswered
JaquesBotha
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Issues with
@apply
Directive and Prefix Configuration in Tailwind CSS v4Problem Summary
I've recently upgraded to Tailwind CSS v4 and encountered the following issues:
1.
@apply
Directive in Custom CSSIn previous versions, I've used the
@apply
directive within my custom CSS files to incorporate utility classes. After upgrading to v4, this approach results in errors indicating that utility classes cannot be found. For example:This suggests that the
@apply
directive is not functioning as it did in earlier versions. If there's a new recommended approach or if@apply
has been deprecated or modified, it would be beneficial to have clear documentation on this transition.Example: Scoped Styling for QuickGrid
2. Prefix Configuration
To prevent class name conflicts, I utilized the prefix feature by importing Tailwind with a prefix:
While this successfully adds the prefix to utility classes, it appears that the Preflight base styles are still applied without the prefix. This leads to unintended styling issues in projects where a prefix is essential to avoid conflicts. Additionally, the documentation on configuring prefixes in v4 seems sparse, making it challenging to implement this feature effectively.
Blazor & TailwindCSS Configuration Issues
Blazor projects, when combined with Webpack and TailwindCSS, can encounter compatibility issues. Specifically:
tailwind.config.js
inside Webpack-managed stylesheets can introduce unexpected behavior.@apply
a crucial feature in these projects.@apply
is restricted.Suggestions
1. Documentation Enhancements
Provide detailed guidance on the usage (or deprecation) of the
@apply
directive in v4, especially concerning its application in custom CSS files.2. Prefix Consistency
Ensure that when a prefix is specified, it uniformly applies to all generated classes, including those from Preflight, or offer a clear method to disable Preflight when using prefixes.
3. Clear Migration Guide
A clear and explicit migration guide for users relying on
@apply
in their custom CSS files would help avoid unnecessary confusion during the upgrade process.I believe addressing these concerns will greatly assist developers in transitioning to and effectively utilizing Tailwind CSS v4.
Thank you for your attention to these matters!
Beta Was this translation helpful? Give feedback.
All reactions