Registry / web-framework / tailwindcss

tailwindcss

JSON →
library0.0.1jsnpmunverified

Tailwind CSS is a highly popular, utility-first CSS framework designed for rapidly building custom user interfaces directly in your markup. The current stable release series is v4.2.2, which represents a significant architectural shift with a new, faster Rust-based engine (Oxide and Lightning CSS) for processing CSS. It has an active release cadence with frequent patch and minor updates. Key differentiators for v4 include its move towards a "CSS-first" configuration model, where customization is primarily handled within CSS files using `@theme` directives, and automatic content detection, simplifying the build process. Unlike previous versions, Tailwind CSS v4 no longer requires PostCSS for its core compilation, as it integrates its own CSS processing pipeline. Dedicated bundler plugins like `@tailwindcss/vite` and `@tailwindcss/webpack` are provided for seamless integration into modern build ecosystems, while still offering a PostCSS compatibility layer via `@tailwindcss/postcss` for existing setups. This version emphasizes performance, a smaller footprint, and leverages modern CSS features like native cascade layers and `color-mix()` for enhanced capabilities and developer experience.

npm install tailwindcss
INSTALL
IMPORT
SIG · TAILWINDCSS
T
tailwindcss
web-frameworkjavascriptv0.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

tailwindcss
import tailwindcss from '@tailwindcss/postcss'
import tailwindcss from 'tailwindcss'
Since v4, the main `tailwindcss` package is no longer a PostCSS plugin. Use `@tailwindcss/postcss` for PostCSS integration.
plugin
import plugin from 'tailwindcss/plugin'
const plugin = require('tailwindcss/plugin')
Used for creating custom Tailwind CSS plugins. While the core configuration is now CSS-first in v4, JavaScript plugins are still supported via this import.
Tailwind CSS in CSS
@import 'tailwindcss';
@tailwind base; @tailwind components; @tailwind utilities;
In Tailwind CSS v4, the old `@tailwind` directives are replaced by a single `@import` statement in your main CSS file.

Demonstrates a basic setup for Tailwind CSS v4.2.2 using the new CSS-first configuration, `@tailwindcss/postcss` plugin, and the CLI to generate CSS. It includes custom theme variables defined via the `@theme` directive.

```typescript // 1. Install necessary packages // npm install -D tailwindcss @tailwindcss/postcss postcss // 2. Create your main CSS file (e.g., src/input.css) // This file now contains your Tailwind import and any CSS-first configurations. // src/input.css /* @import 'tailwindcss'; @theme { --color-brand-500: oklch(0.68 0.28 274); --font-body: ui-sans-serif, system-ui, sans-serif; --space-xxs: 0.25rem; --space-xs: 0.5rem; --space-sm: 0.75rem; } */ // 3. Create a PostCSS configuration file (e.g., postcss.config.mjs) // This registers Tailwind CSS v4 as a PostCSS plugin. // postcss.config.mjs import tailwindcss from '@tailwindcss/postcss'; export default { plugins: { tailwindcss: {}, }, }; // 4. Create an HTML file (e.g., public/index.html) // public/index.html /* <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Tailwind CSS v4 Quickstart</title> <link rel="stylesheet" href="/output.css"> </head> <body> <h1 class="text-brand-500 font-bold text-5xl p-xs">Hello, Tailwind v4!</h1> <p class="text-body text-sm px-sm">This is a paragraph with custom theme colors and spacing.</p> </body> </html> */ // 5. Add a build script to your package.json // The 'tailwindcss' command line tool processes your CSS. // package.json /* { "name": "my-tailwind-app", "version": "1.0.0", "scripts": { "build:css": "tailwindcss -i ./src/input.css -o ./public/output.css --watch" }, "devDependencies": { "tailwindcss": "^4.2.2", "@tailwindcss/postcss": "^4.2.2", "postcss": "^8.4.38" } } */ // 6. Run the build command and open public/index.html // npm run build:css ```
Debug
Known issues
breakingTailwind CSS v4.0 introduces a "CSS-first" configuration, deprecating the `tailwind.config.js` file for theme customization. All theme and plugin configurations are now primarily handled directly within your main CSS file using the `@theme` directive.
fix
Migrate your `tailwind.config.js` settings to the new `@theme` syntax within your main CSS file (e.g., `src/input.css`). Refer to the official v4 migration guide for detailed steps, or use the `@tailwindcss/upgrade` tool.
affects: >=4.0.0
breakingThe `@tailwind base; @tailwind components; @tailwind utilities;` directives are no longer supported in Tailwind CSS v4. They must be replaced by a single `@import 'tailwindcss';` statement in your main CSS entry point.
fix
Update your primary CSS file (e.g., `src/input.css`) to use `@import 'tailwindcss';` instead of the three separate `@tailwind` directives.
affects: >=4.0.0
breakingTailwind CSS v4 no longer ships its core compilation as a PostCSS plugin within the `tailwindcss` package. To use Tailwind v4 with PostCSS, you must install and configure the new dedicated `@tailwindcss/postcss` plugin. Additionally, `autoprefixer` and `postcss-import` are no longer needed as their functionalities are built directly into the v4 engine.
fix
Install `@tailwindcss/postcss` and update your `postcss.config.js` to reference `tailwindcss: {}` (or `@tailwindcss/postcss: {}` if explicit). Remove `autoprefixer` and `postcss-import` from your PostCSS configuration and `devDependencies`.
affects: >=4.0.0
breakingExisting custom JavaScript plugins created for Tailwind CSS v3 are likely incompatible with v4's new Rust-based engine and CSS-first configuration. The plugin API has been significantly revised.
fix
Review and rewrite custom plugins according to the new v4 plugin API documentation. Use the `@tailwindcss/upgrade` tool, but be prepared for manual adjustments in complex plugin scenarios.
affects: >=4.0.0
gotchaTailwind CSS v4 is designed for modern browsers (Safari 16.4+, Chrome 111+, Firefox 128+) and leverages cutting-edge CSS features like cascade layers, registered custom properties (`@property`), and `color-mix()`. This means it will not work or degrade poorly in older browsers.
fix
If supporting older browsers is critical, consider sticking to Tailwind CSS v3.4.x. For v4 projects, ensure your target browser list is compatible with modern CSS features.
affects: >=4.0.0
gotchaTailwind CSS v4 is a full-featured CSS build tool and is not designed to be used with CSS preprocessors like Sass, Less, or Stylus. It handles imports, vendor prefixing, and nesting internally, rendering external preprocessors redundant or conflicting.
fix
Remove Sass, Less, or Stylus from your build pipeline when using Tailwind CSS v4. Leverage Tailwind's built-in capabilities for imports and nesting directly in CSS.
affects: >=4.0.0
Errors
Common errors & fixes
Error: "tailwindcss" is not a PostCSS plugin.
Attempting to use `require('tailwindcss')` directly as a PostCSS plugin in v4, or missing `@tailwindcss/postcss` package.
fix
For PostCSS integration, ensure `@tailwindcss/postcss` is installed and used in your `postcss.config.js` (e.g., `plugins: { tailwindcss: {} }` or `plugins: { '@tailwindcss/postcss': {} }`).
tailwindcss: command not found
The Tailwind CSS CLI is not installed or not accessible in your system's PATH.
fix
Ensure `tailwindcss` is installed as a development dependency (`npm install -D tailwindcss`) and run the command using `npx tailwindcss` or add your `node_modules/.bin` directory to your PATH.
No utility classes were generated. Ensure your content config is correct.
While v4 has automatic content detection, this error can still occur if template files are in non-standard locations, or if the auto-detection heuristics fail for specific project structures.
fix
Review your project structure. If issues persist, refer to the official documentation for manual content configuration options within the v4 CSS-first approach, or consider providing explicit paths if necessary, although this is generally not required for v4.
Unknown @import rule: "tailwindcss"
The `@import 'tailwindcss';` directive in your CSS file is not being processed by the Tailwind CSS PostCSS plugin (if using PostCSS) or the Tailwind CSS CLI is not set up correctly to parse it.
fix
Ensure your build process correctly pipes your CSS through the Tailwind CSS v4 engine. If using PostCSS, verify `@tailwindcss/postcss` is correctly configured in `postcss.config.js` and that PostCSS is applied to your CSS files. If using the CLI, ensure it targets the correct input CSS file containing the `@import`.
Upgrade
Version history
0.0.1latest on npm
Audit
Dependencies
@tailwindcss/postcssoptionalRequired for integrating Tailwind CSS v4 as a PostCSS plugin into existing PostCSS-based build pipelines.
postcssoptionalPeer dependency for `@tailwindcss/postcss` if integrating with PostCSS.
@tailwindcss/viteoptionalRequired for direct integration with Vite as a plugin.
@tailwindcss/webpackoptionalRequired for direct integration with Webpack as a plugin.
Agent activity
3 hits · last 30 days
node
2
Resources