tailwindcss v4.0 @tailwindcss/forms "Unknown word" error #15818
Replies: 13 comments 32 replies
-
Could you provide an example project that reproduces the issue please? |
Beta Was this translation helpful? Give feedback.
-
according to error message i think its due to postcss if the project uses vite try removing the postcss.config file in your project root if it found refer: vite-installation instruction |
Beta Was this translation helpful? Give feedback.
-
Found the problem after debugging this for 5 hours. I had the following text as a class -> |
Beta Was this translation helpful? Give feedback.
-
I'm running into this exact same issue. How did you manage to debug? The stack trace has absolutely 0 debuggable context for me as it doesn't even give me a proper snapshot of the part where the parser failed. I feel like the tailwind upgrade docs are far too simple at the moment. With v3 tailwind would never cause loud runtime errors, any failures would be silent but still build. If it's going to fail, we need a debug path. |
Beta Was this translation helpful? Give feedback.
-
I did a manual debug, meaning i made a copy of my project and started deleting code until the error stopped happening and kept doing that until i found the issue. Maybe there is a better way but that is how i did it. Yeah i was surprised that it caused my program to crash because i thought that classes that are not valid are ignored. Honestly i do not know what other way you could debug it. Because the error stops the css from compiling so you cannot look at the css, and the error message does not give you any information on where the error is in your code or what is causing the error. |
Beta Was this translation helpful? Give feedback.
-
I've tried a few different approaches to debug this and none have worked. Since the error occurs so early in the build during pre-transform I can't get breakpoints to work or even see any output if I alter the postcss plugin file. I've never worked with vite plugins or lightningcss so I'm probably missing something but I don't have the time. Also tried using the vite-plugin-inspector which didn't show me any output from the tailwindcss vite plugin at all once I disabled hmr to stop infinite hot reloads from failed transforms. Maybe because it exited after failing to parse. Will have to wait for a future version of tailwind to upgrade when this problem is addressed. I think putting this validation logic as a vite plugin may be a mistake as it can break builds. Hope to be proven wrong. |
Beta Was this translation helpful? Give feedback.
-
Hi all, I had the same problem. I managed to get my build to work (Svelte 5, latest tailwind install in a new build)) by removing all classes that started with The classes that caused the error:
Once I removed ALL of them (not even 1 could remain, i tested this), the build worked. I honestly don't even remember writing them at this point. This worked with Tailwind 3.4 just fine, so I guess the way Tailwind is parsing is quite different..? |
Beta Was this translation helpful? Give feedback.
-
I just run into the same issue but was unable to solve it by removing |
Beta Was this translation helpful? Give feedback.
-
I also ran into this issue using the tailwind vite plugin (using v 4.0.4), I did not have any of the above mentioned classes (starting with brackets etc.) in my code. For now the only way to fix it was to revert back to the postcss plugin. |
Beta Was this translation helpful? Give feedback.
-
I have to same problem using @font-face with url definition inside one of my css file, the bug is present still v.4.0.9 @font-face {
font-family: 'Roboto';
src: url("/vendor/dragonofmercy/gaia/src/Gui/resources/fonts/roboto-regular.woff") format('woff');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'Roboto';
src: url('/vendor/dragonofmercy/gaia/src/Gui/resources/fonts/roboto-bold.woff') format('woff');
font-weight: bold;
font-style: normal;
}
.font-roboto {
font-family: 'Roboto', sans-serif;
}
The error appear only if I use |
Beta Was this translation helpful? Give feedback.
-
FWIW I tried re-installing all npm packages (deleted node_modules folder and the node-package.lock file) and that worked for me. I was having the exact same error message mentioned here. hope it helps someone. |
Beta Was this translation helpful? Give feedback.
-
I just want to note my wyld journey here, as I tried EVERYTHING (deleting node_modules, deleting all possible dist folders and cache folders) when I commented out a bad classname in my react ts code, and it still threw the error "unknown word". After 1 hour it finally occurred to me, that the way how tailwind is performing its treeshaking and applying its classes to the build output, is by scanning the source code for css-looking strings. And I verified that this also happens for commented-out strings.
When I renamed the commented-out classname, it still threw the same error. |
Beta Was this translation helpful? Give feedback.
-
found error. disable all background-image: url("data:image/svg+xml.... properties error gone. .form-checkbox {
appearance: none;
padding: 0;
print-color-adjust: exact;
display: inline-block;
vertical-align: middle;
background-origin: border-box;
user-select: none;
flex-shrink: 0;
height: 1rem;
width: 1rem;
color: oklch(0.546 0.245 262.881);
background-color: #fff;
border-color: oklch(0.551 0.027 264.364);
border-width: 1px;
--tw-shadow: 0 0 #0000;
border-radius: 0px;
&:focus {
outline: 2px solid transparent;
outline-offset: 2px;
--tw-ring-inset: var(--tw-empty,/*!*/ /*!*/);
--tw-ring-offset-width: 2px;
--tw-ring-offset-color: #fff;
--tw-ring-color: oklch(0.546 0.245 262.881);
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
}
&:checked {
border-color: transparent;
background-color: currentColor;
background-size: 100% 100%;
background-position: center;
background-repeat: no-repeat;
}
/* &:checked {
background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e");
} */
&:checked:hover {
border-color: transparent;
background-color: currentColor;
}
&:checked:focus {
border-color: transparent;
background-color: currentColor;
}
&:indeterminate {
/* background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3e%3cpath stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 8h8'/%3e%3c/svg%3e"); */
border-color: transparent;
background-color: currentColor;
background-size: 100% 100%;
background-position: center;
background-repeat: no-repeat;
}
&:indeterminate:hover {
border-color: transparent;
background-color: currentColor;
}
&:indeterminate:focus {
border-color: transparent;
background-color: currentColor;
}
}
.form-radio {
appearance: none;
padding: 0;
print-color-adjust: exact;
display: inline-block;
vertical-align: middle;
background-origin: border-box;
user-select: none;
flex-shrink: 0;
height: 1rem;
width: 1rem;
color: oklch(0.546 0.245 262.881);
background-color: #fff;
border-color: oklch(0.551 0.027 264.364);
border-width: 1px;
--tw-shadow: 0 0 #0000;
border-radius: 100%;
&:focus {
outline: 2px solid transparent;
outline-offset: 2px;
--tw-ring-inset: var(--tw-empty,/*!*/ /*!*/);
--tw-ring-offset-width: 2px;
--tw-ring-offset-color: #fff;
--tw-ring-color: oklch(0.546 0.245 262.881);
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
}
&:checked {
border-color: transparent;
background-color: currentColor;
background-size: 100% 100%;
background-position: center;
background-repeat: no-repeat;
}
&:checked {
/* background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3ccircle cx='8' cy='8' r='3'/%3e%3c/svg%3e"); */
}
&:checked:hover {
border-color: transparent;
background-color: currentColor;
}
&:checked:focus {
border-color: transparent;
background-color: currentColor;
}
}
.form-input {
appearance: none;
background-color: #fff;
border-color: oklch(0.551 0.027 264.364);
border-width: 1px;
border-radius: 0px;
padding-top: 0.5rem;
padding-right: 0.75rem;
padding-bottom: 0.5rem;
padding-left: 0.75rem;
font-size: 1rem;
line-height: 1.5rem;
--tw-shadow: 0 0 #0000;
&:focus {
outline: 2px solid transparent;
outline-offset: 2px;
--tw-ring-inset: var(--tw-empty,/*!*/ /*!*/);
--tw-ring-offset-width: 0px;
--tw-ring-offset-color: #fff;
--tw-ring-color: oklch(0.546 0.245 262.881);
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
border-color: oklch(0.546 0.245 262.881);
}
&::placeholder {
color: oklch(0.551 0.027 264.364);
opacity: 1;
}
&::-webkit-datetime-edit-fields-wrapper {
padding: 0;
}
&::-webkit-date-and-time-value {
min-height: 1.5em;
}
&::-webkit-date-and-time-value {
text-align: inherit;
}
&::-webkit-datetime-edit {
display: inline-flex;
}
&::-webkit-datetime-edit {
padding-top: 0;
padding-bottom: 0;
}
&::-webkit-datetime-edit-year-field {
padding-top: 0;
padding-bottom: 0;
}
&::-webkit-datetime-edit-month-field {
padding-top: 0;
padding-bottom: 0;
}
&::-webkit-datetime-edit-day-field {
padding-top: 0;
padding-bottom: 0;
}
&::-webkit-datetime-edit-hour-field {
padding-top: 0;
padding-bottom: 0;
}
&::-webkit-datetime-edit-minute-field {
padding-top: 0;
padding-bottom: 0;
}
&::-webkit-datetime-edit-second-field {
padding-top: 0;
padding-bottom: 0;
}
&::-webkit-datetime-edit-millisecond-field {
padding-top: 0;
padding-bottom: 0;
}
&::-webkit-datetime-edit-meridiem-field {
padding-top: 0;
padding-bottom: 0;
}
}
.form-select {
appearance: none;
background-color: #fff;
border-color: oklch(0.551 0.027 264.364);
border-width: 1px;
border-radius: 0px;
padding-top: 0.5rem;
padding-right: 0.75rem;
padding-bottom: 0.5rem;
padding-left: 0.75rem;
font-size: 1rem;
line-height: 1.5rem;
--tw-shadow: 0 0 #0000;
&:focus {
outline: 2px solid transparent;
outline-offset: 2px;
--tw-ring-inset: var(--tw-empty,/*!*/ /*!*/);
--tw-ring-offset-width: 0px;
--tw-ring-offset-color: #fff;
--tw-ring-color: oklch(0.546 0.245 262.881);
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
border-color: oklch(0.546 0.245 262.881);
}
/* background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='oklch(0.551 0.027 264.364)' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e"); */
background-position: right 0.5rem center;
background-repeat: no-repeat;
background-size: 1.5em 1.5em;
padding-right: 2.5rem;
print-color-adjust: exact;
&:where([size]:not([size="1"])) {
background-image: initial;
background-position: initial;
background-repeat: unset;
background-size: initial;
padding-right: 0.75rem;
print-color-adjust: unset;
}
}
.form-textarea {
appearance: none;
background-color: #fff;
border-color: oklch(0.551 0.027 264.364);
border-width: 1px;
border-radius: 0px;
padding-top: 0.5rem;
padding-right: 0.75rem;
padding-bottom: 0.5rem;
padding-left: 0.75rem;
font-size: 1rem;
line-height: 1.5rem;
--tw-shadow: 0 0 #0000;
&:focus {
outline: 2px solid transparent;
outline-offset: 2px;
--tw-ring-inset: var(--tw-empty,/*!*/ /*!*/);
--tw-ring-offset-width: 0px;
--tw-ring-offset-color: #fff;
--tw-ring-color: oklch(0.546 0.245 262.881);
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
border-color: oklch(0.546 0.245 262.881);
}
&::placeholder {
color: oklch(0.551 0.027 264.364);
opacity: 1;
}
}
|
Beta Was this translation helpful? Give feedback.
-
ISSUE
I just upgraded to v4.0 from v3. and when using the
@tailwindcss/forms
plugin i get a"Unknown word"
error. When i remove the@tailwindcss/forms
plugin i do not get this error. I am not sure how to resolve this issue - any help is appreciated. Also, is the@tailwindcss/forms
plugin even needed in v4.0? (i have not been able to test since i cannot get it to work).I HAVE TRIED
@import 'tailwindcss'
and@plugin '@tailwindcss/forms'
but it still did not work.tailwind.config.js
file (even though not needed in v4.0) and it still did not work.REFERENCES
I am using node v20.18.1.
The error message is shown below:

My package.json is shown below:

My vite.config is shown below:

My .css file is shown below:

Beta Was this translation helpful? Give feedback.
All reactions