New to Rust? Grab our free Rust for Beginners eBook Get it free →
100 Tailwind CSS v4 CLI Commands

Before a page can use Tailwind styles, your project needs to turn its stylesheet into a CSS file the browser can load. The Tailwind CSS v4 CLI does that by compiling an input stylesheet into generated CSS.
I’ll show you how to install the CLI and build CSS with your project’s input and output paths.
TL;DR: Use the Tailwind CSS v4 CLI
Tailwind CSS v4 uses the separate @tailwindcss/cli package, an input CSS file that imports Tailwind, and an input/output CLI command.
- Install with npm install tailwindcss @tailwindcss/cli.
- Add the Tailwind CSS import to the input stylesheet.
- Run npx @tailwindcss/cli -i ./src/input.css -o ./src/output.css --watch during development.
What is the Tailwind CSS v4 CLI?
The Tailwind CSS v4 CLI compiles an input stylesheet into generated CSS. Its npm executable comes from the separate @tailwindcss/cli package.
The v3 command npx tailwindcss init is not the v4 setup path. A dynamically assembled string such as text-${color}-600 also lacks a complete class name in source.
How to build CSS with the Tailwind CSS v4 CLI
The documented npm install keeps the CLI packages with the project dependencies.
Step 1: Install the framework and CLI
From the project root, add Tailwind and its CLI as project dependencies. The command below follows the npm setup in the CLI documentation.
npm install tailwindcss @tailwindcss/cli
The project manifest records the requested packages, and the lockfile records the resolved dependency tree. Commit both files so another checkout can install the same dependency graph before running the build.
Step 2: Add Tailwind to the input stylesheet
Create src/input.css and import Tailwind with the regular CSS import used by v4.
@import "tailwindcss";
This import replaces the v3 setup that began with separate @tailwind base, @tailwind components, and @tailwind utilities directives.
Keep authored global CSS in the same stylesheet pipeline as the imported Tailwind rules so the application serves them together.
The CLI is also available as a standalone executable for projects without a Node.js installation. Use that route when the environment cannot use npm packages, and follow the platform-specific installation steps from the official CLI page.
Step 3: Run a build
I ran this command from the workspace with a sample HTML page containing Tailwind classes.
npx @tailwindcss/cli -i ./src/input.css -o ./dist/output.css --minify
The -i option names the stylesheet that imports Tailwind, and -o sets the destination file. Add that destination to the application’s static assets.
The command paths are resolved from the working directory, while an @source path is resolved from the stylesheet that declares it. In a workspace package, check both bases before changing paths to fix a missing input or source folder.
The captured terminal output was:
≈ tailwindcss v4.3.3 Done in 136ms exit status: 0

The command wrote dist/output.css. Its output reports Tailwind v4.3.3 and exit code zero. Configure the application to serve that file.
The minified file is the compiled result for the application to serve as a static asset. Regenerate it from the input stylesheet when source CSS changes.
Step 4: Keep the CLI watching during development
Add --watch to the same input/output invocation when you want a running process to rebuild after file changes.
npx @tailwindcss/cli -i ./src/input.css -o ./dist/output.css --watch
For a one-time compact build, use --minify instead of --watch.
Stop the watch process with the terminal interrupt when development is done.
Step 5: Link the generated CSS
Copy the page’s stylesheet URL from the output location used by the build command.
<link href="/dist/output.css" rel="stylesheet">
Check the browser network panel for a successful request. Then inspect an element that uses a class from your source.
Fix common Tailwind CSS v4 CLI issues
When generated styles are missing, check the package, stylesheet import, source detection, and output link in that order. This separates CLI invocation problems from classes that Tailwind never found.
| Symptom | Check | Fix |
|---|---|---|
| npx tailwindcss cannot find an executable | Are you following v3 instructions? | Install and invoke @tailwindcss/cli. |
| Build runs, expected utility is absent | Is the full class text present in a scanned file? | Use complete class strings or register the source. |
| Classes in an ignored or dependency directory are missing | Does automatic detection skip that path? | Add an @source path in the input CSS. |
| Styles compile but page is unstyled | Does the browser request the generated output? | Correct the HTML link or framework asset import. |
Automatic detection skips Git-ignored files and node_modules. Register a dependency directory relative to the stylesheet when it supplies classes:
@import "tailwindcss"; @source "../node_modules/@acmecorp/ui-lib";
Check what the dependency actually ships. If it contains templates with utility names, register those source files. If it provides a compiled CSS file instead, import that stylesheet into your CSS entry rather than expecting source scanning to read CSS as templates.
Tailwind also excludes CSS files, binaries, and package-manager lockfiles from automatic detection.
Use an inline source directive for a finite utility set absent from templates. Brace expansion can include variant forms, so keep the list specific to selectors the build needs.
The upgrade guide lists core plugin toggles, safelists, and custom separators among v3 options without a v4 equivalent.
For separate application outputs in a monorepo, source(none) disables automatic detection so each stylesheet can name only the source folders it needs.
The official upgrade command for a v3 project requires Node.js 20 or higher and should run on a new branch before review and testing.
The upgrade guide lists minimum versions of Safari 16.4, Chrome 111, and Firefox 128 for v4.
| Browser | Minimum version listed by Tailwind |
|---|---|
| Safari | 16.4 |
| Chrome | 111 |
| Firefox | 128 |
If a required browser is older than the listed minimum, the upgrade guide recommends staying on v3.4 until support requirements change.
The CLI does not select a browser target from your package configuration. Treat browser support as a separate release decision and test the compiled page in the versions your application promises to support.
Vite uses Tailwind’s Vite plugin, while PostCSS uses its dedicated package. The Next.js Tailwind CSS setup guide covers that framework.
Check what the CLI scans
The mapping also makes the accepted status values visible in one place. Add another entry when the component gains a supported state.
const classes = {
error: "text-red-600",
success: "text-green-600",
};
const className = classes[status];
Give the status value a finite type when it is controlled by your application. If a service supplies it, check the value before indexing the object and select a fallback for an unrecognized status. That prevents an absent mapping from becoming an empty class attribute.
Register sources that automatic detection misses
Choose a utility unique to the dependency when checking the generated file.
grep -o '\\.text-3xl' dist/output.css
A missing match points back to detection or the class name itself.
Choose the right customization route
Use a theme block for tokens that should create utilities. A CSS custom property fits a component-only value.
@theme {
--color-brand: #316ff6;
}
.card {
color: var(--color-brand);
}
The color namespace makes this token available through utilities such as text-brand and bg-brand. The regular CSS declaration can also use the same variable directly, and new theme values extend the defaults, so reset a namespace only when the project intends to replace its built-in values. Check the generated CSS after changing theme settings, since this confirms which utility names the stylesheet contains and catches typos before you link the file in your application.
The v4 CLI does not automatically load a JavaScript configuration file. Add the documented configuration directive when retaining supported legacy settings, then verify the settings that affect your design system.
Core plugin toggles, safelists, and custom separators from v3 have no v4 equivalent.
Use Tailwind’s reference directive when a separately processed Vue or Svelte style block needs the main stylesheet’s theme values. It exposes those values and custom utilities without copying the generated styles into that file.
The CLI is a good fit when a project wants a direct CSS build command. A framework plugin can instead join Tailwind processing to that framework’s existing build pipeline. Avoid running both routes on the same stylesheet unless the project deliberately needs two separate outputs.
The distinction matters when a framework already bundles CSS. In that setup, adding a second CLI build for the same stylesheet can create two generated files and leave the page loading the wrong one. Trace the stylesheet from its source import to the asset URL used by the framework.
A direct CLI command is also useful in CI because its input and output paths are visible in the script. Keep CI’s working directory consistent with local development, especially when the repository contains several applications.
In the PostCSS setup, v4 handles imports and vendor prefixing automatically. Review existing plugins before keeping older import or prefixing steps in the configuration.
Tailwind v4 is designed for plain CSS rather than Sass, Less, or Stylus. Treat the Tailwind build as the stylesheet processor, then use its CSS directives for imports and theme configuration.
Verify the output in the application
<link href="/dist/output.css" rel="stylesheet">
In the network panel, verify the stylesheet request and inspect a known utility’s computed style. If the property is crossed out, another CSS rule overrides it.
The leading slash in the example makes the URL root-relative. If your site is deployed under a subpath, use the asset URL your framework or server actually exposes rather than copying that path unchanged.
Store the successful development or production command in the matching package script. Then check the script from the same working directory used by your build pipeline.
Conclusion: Keep the CLI command small
Keep the input stylesheet and the command that builds it together in the project scripts.
Use the official Tailwind CLI installation guide for the current setup, then check the Next.js CSS Modules and global CSS guide when adapting application styles.
FAQ
These answers cover the package and source-detection differences that commonly affect a v4 CLI setup.
What package provides the Tailwind CSS v4 CLI?
Install the tailwindcss framework package and the separate @tailwindcss/cli package. Invoke it with npx @tailwindcss/cli.
Does Tailwind CSS v4 CLI use the init command?
The current v4 CLI installation uses an input CSS file with @import “tailwindcss” and an input/output build command. The old v3 init workflow is not the documented setup.
How do I make the Tailwind v4 CLI scan another folder?
Add an @source directive in the input stylesheet. Its path is resolved relative to that stylesheet. You can also set a base path with source() in the import.




