More packages - but why?
In Tailwind CSS v3, the tailwind.config.js
file was still required. To make creating it easier, a CLI init
process was available: npx tailwindcss init -p
.
Starting with v4, the tailwind.config.js
file is no longer needed (more on that here: What is the CSS-first configuration), and therefore the init
process for generating it is no longer necessary either. As a result, there's no longer any justification to bundle the entire CLI ecosystem into every project - especially those that integrate Tailwind CSS via PostCSS or a Vite plugin instead of using the CLI.
Separated package for Tailwind CLI
It made sense to separate the CLI into its own package, now named @tailwindcss/cli
, which only needs to be installed by those who want to use the Tailwind CLI.
$ npm install tailwindcss @tailwindcss/cli
Note: Remember, the new separate official CLI command is: npx @tailwindcss/cli
.
$ npx tailwindcss -i input.css -o output.css$ npx @tailwindcss/cli -i input.css -o output.css
Separated package for PostCSS integration
Once the CLI was separated, it became obvious that the PostCSS plugin should also be isolated. It was moved into a separate package named @tailwindcss/postcss
, which only needs to be installed by those integrating Tailwind via PostCSS.
$ npm install tailwindcss @tailwindcss/postcss postcss
- Install Tailwind CSS using PostCSS
- Custom guide to Next.js - Install Tailwind CSS using PostCSS
- Custom guide to Laravel Mix - Install Tailwind CSS using PostCSS
Note: Accordingly, in your PostCSS configuration, you should now load the separated package as the plugin instead of the main package.
export default { plugins: { "postcss-import": {}, tailwindcss: {}, autoprefixer: {}, "@tailwindcss/postcss": {}, },};
Due to the structure of the separated package, there is no need for the postcss-import
and autoprefixer
packages anymore.
$ npm uninstall postcss-import autoprefixer
New Vite plugin
Up to v3, Vite users could install Tailwind CSS via PostCSS. But this changed in v4, which introduced a dedicated plugin for direct Vite integration under the new package name @tailwindcss/vite
. This means Vite users no longer need to rely on PostCSS to use Tailwind CSS.
# If your Vite project does not exist yet$ npm create vite@latest my-app-name$ cd my-app-name$ npm install tailwindcss @tailwindcss/vite
- Scaffolding Your First Vite Project
- Install Tailwind CSS using Vite
- Custom guide to Laravel - Install Tailwind CSS using Vite
Installation fails based on an old online tutorial
Accordingly, all official installation guides have been updated. However, caution is needed when following outdated, unofficial tutorials found online. Running npm install tailwindcss
now installs the new v4 version, which no longer includes the init
process and doesn't use tailwind.config.js
, even if you create it manually.
# Do not use it; just an example of incorrect usage starting from January 2025$ npm install tailwindcss postcss autoprefixer$ npx tailwindcss init -p> Error: tailwindcss not recognized
Note: If you follow a similar old - now outdated - installation step, you will end up installing Tailwind CSS v4 instead of v3, but you won't install any of the additional packages mentioned above. If you want to use the PostCSS plugin as described in the v3 documentation, it won't work, and you will receive a warning indicating that something went wrong:
[postcss] It looks like you're trying to use tailwindcss directly as a PostCSS plugin. The PostCSS plugin has moved to a separate package, so to continue using Tailwind CSS with PostCSS you'll need to install
@tailwindcss/postcss
and update your PostCSS configuration
Solutions:
How to install old Tailwind CSS v3?
If you want to follow guides written for Tailwind CSS v3, you must perform a version-specific installation, as now noted in the updated v3 documentation:
$ npm install tailwindcss@3$ npx tailwindcss init
Although Tailwind CSS v3 installation often appears as the first recommendation in many places, I believe that if the browser support offered by v4 (which is quite broad but not critical) is acceptable for your project, you should definitely base your work on v4. It receives active maintenance and will continue to evolve in the coming times.