TL;DR: Use @config directive.
From v4 onwards, the use of the tailwind.config.js file has been removed, and CSS-first directives are provided for configuration. The init process, which previously generated this config file by default, has also been discontinued. If you want to use a JS-based config file from v4 onwards, you must create it manually and specify its location in CSS using the @config directive so that v4 can find the configuration.
- Changed
npx tailwindcsstonpx @tailwindcss/cli- TailwindCSS v4 Docs - Removed
npx tailwindcss initprocess - StackOverflow - Deprecated: Sass, Less and Stylus preprocessors support - StackOverflow
- CSS-first configuration instead of
tailwind.config.js- TailwindCSS v4 Docs - Use
@configdirective to legacy JavaScript-config - StackOverflow - Automatic Source Detection - StackOverflow
TailwindCSS v4 is backwards compatible with v3
I see that you've created the old v3 legacy JavaScript-based configuration. In v4, this is no longer necessary due to the new CSS-first configuration, but you can still use it by adding an extra @config directive if needed.
Using a JavaScript config file
JavaScript config files are still supported for backward compatibility, but they are no longer detected automatically in v4.
If you still need to use a JavaScript config file, you can load it explicitly using the @config directive:
@config "../../tailwind.config.js";
- Using a JavaScript config file - TailwindCSS v4 Update Guide
The configuration setting has changed by default. However, you have the option to declare the location of your tailwind.config.js file using a relative path in your default CSS file so you can use it again.
New configuration option in v4
CSS-First Configuration: Customize and extend the framework directly in CSS instead of JavaScript.
With TailwindCSS v4, you have the option to omit the tailwind.config.js file. You can find many new directives, such as @theme, which allows you to declare your custom settings directly in your CSS file, or @plugin, which lets you import TailwindCSS v4-compatible plugins directly in your CSS file.
I won't list all the new directives, but you can check them out here:
- Functions and directives - TailwindCSS v4 Docs
So I was starting a new vite-react tailwind project and tailwind has been updated to v4 just recently. Was gonna create some new themes config but no `tailwind.config.js` files were being generated.
After some research and experimentation, finally made it work!
Update from Tailwind Docs:
Instead of a
tailwind.config.jsfile, you can configure all of your customizations directly in the CSS file where you import Tailwind, giving you one less file to worry about in your project:
Also, if you aren't sure how to initialize the project or make a new tailwind css project, you can follow this guide: https://drive.google.com/file/d/1mlmO0e479nASrxJ-YLImHoxpmwCymLHs/view , credits to: https://www.youtube.com/watch?v=-JDCFN0Znj8
Hope this helps ya'll! I couldn't post it on StackOverflow cuz I only recently made a new account.
Mar 17, 2025 Edit: this guy has a more in-depth explanation and fix to this new update. Including the content, plugins, etc:
New CSS-First configuration