Missing Utility Classes ("bg-bglight" and "w-3") When Using @apply in Global CSS #17121
Unanswered
tianyinggang
asked this question in
Help
Replies: 1 comment 3 replies
-
You seem to be using v3 syntax but you have v4 installed. You'd want to replace the -@tailwind base;
-@tailwind components;
-@tailwind utilities;
+@import "tailwindcss"; Then, you could consider loading your JavaScript configuration: @import "tailwindcss";
/* Path relative to the CSS file. */
@config "../../tailwind.config.js"; Though really, you should consider using CSS configuration instead. As an aside, Adam Wathan (creator of Tailwind) does seem to advocate avoiding |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What version of Tailwind CSS are you using?
For example: v3.2.7
What build tool (or framework if it abstracts the build tool) are you using?
For example: Next.js 15.2.1
What version of Node.js are you using?
For example: v20.0.0
What browser are you using?
For example: Chrome
What operating system are you using?
For example: macOS
Reproduction URL:
Please refer to this minimal reproduction: Link to a minimal GitHub repo or Tailwind Play reproduction
(Note: Replace the placeholder with your actual reproduction URL. Make sure the reproduction is isolated from your main project.)
Describe your issue:
I am experiencing a build error when using the
@apply
directive in my global CSS file. In my Tailwind configuration (tailwind.config.js
), I have extended the theme with custom colors and I expect utility classes likebg-bglight
to be generated automatically. However, when I use@apply bg-bglight;
in my global CSS file, I get the following error during build:Additionally, a default utility class like
w-3
is also not recognized in a similar scenario. Mytailwind.config.js
includes the following relevant configuration:This is tailwind.config.js:
This is src/app/globals.css:
this is package.json:
I have verified that the
content
array includes all the paths for my source files. However, since my global CSS file (where I use@apply
) is not being scanned, the custom utility class is not generated, leading to the error.Steps I’ve tried as a workaround:
Expected Behavior:
Tailwind CSS should generate the utility classes (e.g.,
bg-bglight
andw-3
) so that using@apply
with these classes in any CSS file (including global CSS) works without error.Any help or guidance on this issue would be greatly appreciated. Thank you!
Beta Was this translation helpful? Give feedback.
All reactions