npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

tailwindcss-atomic

v1.0.5

Published

atomic css classes for tailwindcss. support vite, webpack, rollup and next.js!

Readme

tailwindcss-atomic

Plugin para Tailwind CSS que convierte cada declaración en una clase atómica (_aa7b5f) y reescribe los className del JavaScript/TypeScript para que coincidan.

Sirve con PostCSS, Vite, Webpack, Rollup y Next.js.

Instalación

pnpm add -D tailwindcss-atomic

Peer: postcss ≥ 8. Node.js ≥ 22.18.0. Webpack ≥ 5 es opcional (solo si usas ese bundler). sass es peer opcional: hace falta para warmup de entradas .scss / .sass con @use locales.

Cómo encaja en el pipeline

  1. Tailwind (v3 o v4) expande @tailwind / @import "tailwindcss".
  2. El plugin de PostCSS debe ir después de Tailwind: lee esas reglas, las parte y arma el mapa flex_215464.
  3. El plugin del bundler (o el loader de Next) sustituye strings en JSX y en llamadas a cn, clsx, classnames y cva.

Sin el paso 2 el CSS no se atomiciza. Sin el paso 3 el DOM sigue con flex y p-6.

PostCSS

Tailwind v4:

// postcss.config.mjs
export default {
	plugins: {
		"@tailwindcss/postcss": {},
		"tailwindcss-atomic/postcss": {},
	},
};

Tailwind v3 (Vite o Next 12): el plugin va después de tailwindcss y autoprefixer.

// postcss.config.js
module.exports = {
	plugins: {
		tailwindcss: {},
		autoprefixer: {},
		"tailwindcss-atomic/postcss": {},
	},
};

Next.js 15 (App Router, Tailwind 4)

// next.config.ts
import {withTailwindAtomic} from "tailwindcss-atomic/next";

const nextConfig = {reactStrictMode: true};

export default withTailwindAtomic(nextConfig);

Hay un ejemplo en app/next-app (pnpm dev, puerto 3016).

Next.js 15 + Tailwind 3 + SCSS

Tailwind v3 no expande @use 'tailwindcss/utilities'; espera @tailwind utilities. Si la entrada es SCSS (por ejemplo scss/styles.scss importada desde app/layout.tsx) el warmup normaliza esas capas y, si está instalado sass, compila los @use locales antes de PostCSS. Así el mapa flex_xxxxxx existe antes de que Webpack transforme los bundles de App Router (client, SSR y RSC).

// scss/styles.scss
@use 'tailwindcss/base';
@use 'tailwindcss/components';
@use 'tailwindcss/utilities';
@use './themes/brand' as themes;
// app/layout.tsx
import "../scss/styles.scss";
// postcss.config.js — el plugin atomic va el último
module.exports = {
	plugins: {
		"postcss-import": {},
		"tailwindcss/nesting": {},
		tailwindcss: {},
		autoprefixer: {},
		"tailwindcss-atomic/postcss": {},
	},
};
// next.config.ts
import {withTailwindAtomic} from "tailwindcss-atomic/next";

export default withTailwindAtomic({reactStrictMode: true});

withTailwindAtomic inyecta el loader de Webpack (pre) y el plugin que, en processAssets, atomiciza todo el CSS y después reescribe todo el JS (incluidos chunks de servidor). En next dev invalida módulos JS cuando cambia el mapa.

El path clásico app/globals.css con @tailwind base/components/utilities sigue igual.

Next.js 15 + Turbopack

// next.config.ts
import {withTailwindAtomic} from "tailwindcss-atomic/next";

export default withTailwindAtomic({
	reactStrictMode: true,
});
{ "scripts": { "dev": "next dev --turbopack --port 3019" } }

withTailwindAtomic rellena turbopack.rules con el loader de TS/JS (además del hook de Webpack). El PostCSS de Tailwind 4 sigue siendo obligatorio. Ejemplo: app/next-turbo-app (pnpm dev:turbo).

Next.js 12 (Pages Router, Tailwind 3)

// next.config.mjs
import {withTailwindAtomic} from "tailwindcss-atomic/next";

export default withTailwindAtomic({
	reactStrictMode: true,
});

Usa pages/, styles/globals.css con @tailwind base/components/utilities y el PostCSS de v3 de arriba. Ejemplo: app/next12-app (pnpm dev:next12, puerto 3018).

Vite (Tailwind 3)

import {defineConfig} from "vite";
import react from "@vitejs/plugin-react";
import tailwindAtomic from "tailwindcss-atomic/vite";

export default defineConfig({
	plugins: [react(), tailwindAtomic()],
});

Ejemplo: app/vite-app (pnpm dev:vite, puerto 3017).

Webpack

const tailwindAtomic = require("tailwindcss-atomic/webpack");

module.exports = {
	plugins: [tailwindAtomic()],
};

Rollup

import tailwindAtomic from "tailwindcss-atomic/rollup";

export default {
	plugins: [tailwindAtomic()],
};

Opciones

type Options = {
	/** Funciones cuyos argumentos de string se reescriben. */
	targetFunctions?: Set<string>;
	/** CSS de Tailwind ya compilado, para precargar el mapa (poco habitual). */
	tailwindCss?: string;
};

Por defecto targetFunctions es cn, clsx, classnames y cva. También se reescriben atributos JSX className y props className/class de jsx / jsxs / jsxDEV.

withTailwindAtomic(nextConfig, {
	targetFunctions: new Set(["cn", "clsx", "tw"]),
});

Qué se conserva

El WASM solo toca reglas de utilidad (selectores con .). Se dejan intactos @theme, :root, preflight, @keyframes y at-rules anidadas (@media, @supports, @container) en el sentido de que el contenedor se recorre y las utilidades de dentro sí se atomicizan.

Licencia

MIT. El texto completo está en el archivo LICENSE de este repositorio.