[v4] Cannot apply unknown utility class #13336
-
I have a seperate utilities.css file containing @import from other subfolders ('form/buttons.css', 'form/inputs.css', etc). I keep getting this error:
app.css
utilities.css
components.css
Components usualy use my custom utility classes for example flex-start The CSS folder structure:
What am I missing? |
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 39 replies
-
Bump! Anyone got any ideas what's causing the error? |
Beta Was this translation helpful? Give feedback.
-
Sounds like you're trying to do |
Beta Was this translation helpful? Give feedback.
-
For anyone looking after upgrading to v4: If you have a main css file where you have |
Beta Was this translation helpful? Give feedback.
-
I'm quite shocked at the fact that they push Tailwind 4 on us with such integral changes yet not document certain parts (IE:@apply) clearly. Don't force core changes on us if you not 110% ready. I've tried everything from trying to include the old tailwind.config file within css to @reference within the css file, NOTHING is working when it comes to @apply. Clearly not thought over properly. Here's an example of what I'm refering to:
If sometone knows of a solution please comment |
Beta Was this translation helpful? Give feedback.
-
Hi, After upgrading to Tailwind CSS v4, I'm encountering errors like "[plugin:vite:css] [postcss] Cannot apply unknown utility class: text-gray-200," despite using @reference. my app.css file looks like below
In my datatable.css, I have
|
Beta Was this translation helpful? Give feedback.
-
Without <style lang="postcss">
.test-pre {
@apply break-words whitespace-pre-wrap;
}
</style> but this ↓ throws error <style lang="postcss">
.test-color {
@apply bg-white;
}
</style> What is the difference? |
Beta Was this translation helpful? Give feedback.
-
I opened a bug report for this. Honestly love debating but I dont have time and need a solution... |
Beta Was this translation helpful? Give feedback.
-
I looked into the upgrade guide but did not find what broke it |
Beta Was this translation helpful? Give feedback.
-
same error, it seems to think that
@import "tailwindcss";
input {
padding: 6px;
@apply mt-1 block w-full rounded-md border border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50;
} |
Beta Was this translation helpful? Give feedback.
-
is it terrible to link to a global css file or just directly import into each tailwindcss component? Can I do this? I also encountered this problem in the next section 3. |
Beta Was this translation helpful? Give feedback.
Sounds like you're trying to do
@apply flex-center
somewhere — v4 doesn't currently support applying custom classes, only classes that are built in to the framework, so this just won't work quite yet. Will be in there eventually though before the real v4 release 👍