Import
As of TailwindCSS v4, the @tailwind directive has been removed. So none of those declarations are needed anymore. Instead, you only need a single import at the top of your CSS file:
@import "tailwindcss";
@config "../../tailwind.config.js";
Prefix
If you want to use a prefix, you need to include the import again at the top of the file, like this:
@import "tailwindcss" prefix(tw);
@config "../../tailwind.config.js";
Among my other observations, I'd note that the mode: "jit" setting in the config file has been deprecated since TailwindCSS v3, as JIT mode has been the default since then.
Starting from v4, if you're using the legacy JavaScript configuration, you no longer need to define prefix: "tw" in the config file either; as mentioned, this should now be specified during import.
Also, from TailwindCSS v4 onward, you don't need to define the content option; v4 automatically discovers your source files (excluding paths listed in .gitignore).
Note: Make sure that the files listed in the .gitignore are not considered by TailwindCSS when compiling the CSS. It is possible to override the gitignore using the @source directive (e.g., if you want to exclude node_modules but need some class names from one or two packages). See more details here: TailwindCSS v4 does not apply styles in packages/components.
So if you still want to use the tailwind.config.js, this is all you need to keep from the current configuration:
/** @type {import('tailwindcss').Config} */
export default {
theme: {
colors: {
'green': '#4287f5'
}
}
}
If you don't want to overwrite all the original TailwindCSS colors (e.g., bg-red-500, etc.) and just want to extend them with your own, use the extend property like this:
/** @type {import('tailwindcss').Config} */
export default {
theme: {
extend: {
colors: {
'green': '#4287f5'
}
}
}
}
CSS-first configuration (recommended from v4)
As of v4, you don’t actually need a tailwind.config.js anymore. So you can leave it out and use the new CSS-first configuration instead. Based on your current config file, it would look like this:
@import "tailwindcss" prefix(tw);
@theme {
--color-green: #4287f5; /* extend default colors with new green, what can use as e.g. tw:bg-green */
}
Note: In this case, there's no need for the tailwind.config.js anymore!
Of course, if you don't need a prefix after all, then use it like this:
@import "tailwindcss";
@theme {
--color-green: #4287f5; /* extend default colors with new green, what can use as e.g. bg-green */
}
More breaking changes from v4
Since v4, several breaking changes have been introduced; it's worth reviewing all of them.
tw:top-0andtw:left-0aren't being applied. If I had to guess, I'd say it’s a specificity issue.importshould be done at the top of the file; there’s no need for@tailwind;@configis a backward solution, but it's no longer mandatory to use a config file (I suggest reviewing the links I attached). I hope the answer was helpful.