{"versions":{"0.0.1":{"name":"css-to-tailwindcss4","type":"module","version":"0.0.1","packageManager":"pnpm@11.1.1","description":"css to tailwindcss4 converter","author":{"name":"REFINIST"},"license":"MIT","homepage":"https://github.com/refinist/css-to-tailwindcss4#readme","repository":{"type":"git","url":"git+https://github.com/refinist/css-to-tailwindcss4.git"},"bugs":{"url":"https://github.com/refinist/css-to-tailwindcss4/issues"},"keywords":["css","tailwind","tailwindcss","tailwindcss4","tailwind-v4","converter","postcss"],"exports":{".":"./dist/index.mjs"},"types":"./dist/index.d.mts","engines":{"node":"^22.18.0 || >=24.0.0"},"scripts":{"build":"tsdown src/index.ts","test":"vitest run","test:coverage":"vitest run --coverage","test:watch":"vitest","typecheck":"tsgo --noEmit","lint":"eslint --cache --max-warnings 0 .","lint:fix":"pnpm lint --fix","format":"prettier --write --cache ."},"dependencies":{"colord":"^2.9.3","postcss":"^8.5.14","postcss-safe-parser":"^7.0.1","postcss-selector-parser":"^7.1.1"},"devDependencies":{"@refinist/eslint-config":"^1.3.0","@refinist/prettier-config":"^1.2.0","@types/node":"^25.7.0","@typescript/native-preview":"7.0.0-dev.20260514.1","@vitest/coverage-v8":"^4.1.6","bumpp":"^11.1.0","eslint":"^10.3.0","postcss-nested":"^7.0.2","prettier":"^3.8.3","tsdown":"^0.22.0","typescript":"^6.0.3","vite":"^8.0.12","vitest":"^4.1.6"},"prettier":"@refinist/prettier-config","_id":"css-to-tailwindcss4@0.0.1","_nodeVersion":"24.15.0","_npmVersion":"11.12.1","dist":{"integrity":"sha512-gnOIF1Zq3+n1G5pocFfsBHjxOE2bgUUAWTEcLUoWN8GqUn1wTmX292O8O4Dm5XuX186ceKM+YZq5LtZLyonHLQ==","shasum":"6437e50b19f612b0f2965bbc9a58912094f57b6d","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/css-to-tailwindcss4/-/css-to-tailwindcss4-0.0.1.tgz","fileCount":6,"unpackedSize":119017,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIArXBfxyyYjhYrYcZVpz5bjvXEeGQV7ayTnzg4GZVf7CAiBPVdFSZYMA3XrBwB2HwXqJedX1bGgQZeGemhB/pGyGWQ=="}],"size":29661},"_npmUser":{"name":"anonymous","email":"229298746@qq.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"229298746@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/css-to-tailwindcss4_0.0.1_1778752875814_0.04902711241669988"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-05-14T10:01:15.960Z","publish_time":1778752875960,"_source_registry_name":"default","contributors":[]},"0.0.2":{"name":"css-to-tailwindcss4","type":"module","version":"0.0.2","description":"css to tailwindcss4 converter","author":"REFINIST","license":"MIT","homepage":"https://github.com/refinist/css-to-tailwindcss4#readme","repository":{"type":"git","url":"git+https://github.com/refinist/css-to-tailwindcss4.git"},"bugs":{"url":"https://github.com/refinist/css-to-tailwindcss4/issues"},"keywords":["css","tailwind","tailwindcss","tailwindcss4","tailwind-v4","converter","postcss"],"exports":{".":"./dist/index.mjs"},"types":"./dist/index.d.mts","engines":{"node":"^22.18.0 || >=24.0.0"},"dependencies":{"colord":"^2.9.3","postcss":"^8.5.14","postcss-safe-parser":"^7.0.1","postcss-selector-parser":"^7.1.1"},"devDependencies":{"@refinist/eslint-config":"^1.3.0","@refinist/prettier-config":"^1.2.0","@types/node":"^25.7.0","@typescript/native-preview":"7.0.0-dev.20260514.1","@vitest/coverage-v8":"^4.1.6","bumpp":"^11.1.0","eslint":"^10.3.0","postcss-nested":"^7.0.2","prettier":"^3.8.3","tsdown":"^0.22.0","typescript":"^6.0.3","vite":"^8.0.12","vitest":"^4.1.6"},"prettier":"@refinist/prettier-config","scripts":{"build":"tsdown src/index.ts","test":"vitest run","test:coverage":"vitest run --coverage","test:watch":"vitest","typecheck":"tsgo --noEmit","lint":"eslint --cache --max-warnings 0 .","lint:fix":"pnpm lint --fix","format":"prettier --write --cache .","release":"bumpp"},"_nodeVersion":"24.14.1","_id":"css-to-tailwindcss4@0.0.2","dist":{"integrity":"sha512-WqcdsJuMEyYw6mbUzDPdZi3X2oi4FcOzj9/5ANedIKvfYCkCLhTLl1QsIQR1xcNXwiKLD/AEh2gdIpBmMhI4hg==","shasum":"6de5936dcb4668bf34e6dd2d84d6ee383f6b7ac6","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/css-to-tailwindcss4/-/css-to-tailwindcss4-0.0.2.tgz","fileCount":6,"unpackedSize":120868,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/css-to-tailwindcss4@0.0.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIFLpsbJ3qBQXb+yb7ixX+lCpzYvTUBaka8orMe0hV3vZAiAfScNcZ5BBlMm6JvHxroE+DKFu7wGFzg66JKoj2RKFMw=="}],"size":30017},"_npmUser":{"name":"anonymous","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:f6bf16a7-7d50-4800-abdf-8e2b29209017"}},"directories":{},"maintainers":[{"name":"anonymous","email":"229298746@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/css-to-tailwindcss4_0.0.2_1778766857004_0.8140677134089918"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-05-14T13:54:17.198Z","publish_time":1778766857198,"_source_registry_name":"default","contributors":[]},"0.0.3":{"name":"css-to-tailwindcss4","type":"module","version":"0.0.3","description":"css to tailwindcss4 converter","author":{"name":"REFINIST"},"license":"MIT","homepage":"https://github.com/refinist/css-to-tailwindcss4#readme","repository":{"type":"git","url":"git+https://github.com/refinist/css-to-tailwindcss4.git"},"bugs":{"url":"https://github.com/refinist/css-to-tailwindcss4/issues"},"keywords":["css","tailwind","tailwindcss","tailwindcss4","tailwind-v4","converter","postcss"],"exports":{".":"./dist/index.mjs"},"types":"./dist/index.d.mts","engines":{"node":"^20.19.0 || >=22.12.0"},"dependencies":{"colord":"^2.9.3","postcss":"^8.5.14","postcss-safe-parser":"^7.0.1","postcss-selector-parser":"^7.1.1"},"devDependencies":{"@refinist/eslint-config":"^1.3.0","@refinist/prettier-config":"^1.2.0","@tailwindcss/node":"^4.3.2","@types/node":"^25.7.0","@typescript/native-preview":"7.0.0-dev.20260514.1","@vitest/coverage-v8":"^4.1.6","bumpp":"^11.1.0","eslint":"^10.3.0","postcss-nested":"^7.0.2","prettier":"^3.8.3","tailwindcss":"^4.3.2","tsdown":"^0.22.0","typescript":"^6.0.3","vite":"^8.0.12","vitest":"^4.1.6"},"prettier":"@refinist/prettier-config","scripts":{"build":"tsdown src/index.ts","test":"vitest run","test:coverage":"vitest run --coverage","test:watch":"vitest","typecheck":"tsgo --noEmit","lint":"eslint --cache --max-warnings 0 .","lint:fix":"pnpm lint --fix","format":"prettier --write --cache .","release":"bumpp"},"_id":"css-to-tailwindcss4@0.0.3","_integrity":"sha512-qNPGPRJLatiymPm2DsMg7l4j29VrCaRv+8Bcq5sbkV+OhlTrzWhEjNIrtkiSwhUMgWXozcIvtFV0LSL52XwTXg==","_resolved":"/tmp/a199511558a6431458a9779833675b69/css-to-tailwindcss4-0.0.3.tgz","_from":"file:css-to-tailwindcss4-0.0.3.tgz","_nodeVersion":"24.18.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-qNPGPRJLatiymPm2DsMg7l4j29VrCaRv+8Bcq5sbkV+OhlTrzWhEjNIrtkiSwhUMgWXozcIvtFV0LSL52XwTXg==","shasum":"83ac5ee116aaf01262619e5c189f222d8912f80a","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/css-to-tailwindcss4/-/css-to-tailwindcss4-0.0.3.tgz","fileCount":6,"unpackedSize":126549,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/css-to-tailwindcss4@0.0.3","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDj/u6fJizAwTopsgzR8viBtZFipXmxkPY4QIW6ifQO4QIgbrsS6WVnkdB9HJf6YvyjZRVYiyoFoxDlKHtAQsnCQqU="}],"size":31535},"_npmUser":{"name":"anonymous","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:f6bf16a7-7d50-4800-abdf-8e2b29209017"}},"directories":{},"maintainers":[{"name":"anonymous","email":"229298746@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/css-to-tailwindcss4_0.0.3_1783305600584_0.407708603276395"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-07-06T02:40:00.720Z","publish_time":1783305600720,"_source_registry_name":"default","contributors":[]}},"dist-tags":{"latest":"0.0.3"},"name":"css-to-tailwindcss4","time":{"created":"2026-05-14T10:01:28.458Z","modified":"2026-07-06T02:40:17.484Z","0.0.1":"2026-05-14T10:01:15.960Z","0.0.2":"2026-05-14T13:54:17.198Z","0.0.3":"2026-07-06T02:40:00.720Z"},"readme":"# css-to-tailwindcss4\n\nEnglish | [中文](./README.zh-CN.md)\n\n[![npm](https://img.shields.io/npm/v/css-to-tailwindcss4.svg?colorA=00bcff&colorB=000000)](https://npmjs.com/package/css-to-tailwindcss4) [![downloads/month](https://img.shields.io/npm/dm/css-to-tailwindcss4.svg?colorA=00bcff&colorB=000000)](https://npmjs.com/package/css-to-tailwindcss4) [![Unit Test](https://img.shields.io/github/actions/workflow/status/refinist/css-to-tailwindcss4/unit-test.yml?colorA=00bcff&colorB=000000&label=Unit%20Test)](https://github.com/refinist/css-to-tailwindcss4/actions/workflows/unit-test.yml) [![codecov](https://img.shields.io/codecov/c/github/refinist/css-to-tailwindcss4?colorA=00bcff&colorB=000000)](https://codecov.io/github/refinist/css-to-tailwindcss4)\n\nConvert CSS to Tailwind CSS v4 utility classes.\n\n> This project follows the core conversion approach of [`css-to-tailwindcss`](https://github.com/Jackardios/css-to-tailwindcss) and updates it for Tailwind CSS v4's CSS-first theme, utility names, and syntax changes.\n\n## ✨ Features\n\n- 🧱 Supports common Tailwind CSS v4 utilities across layout, flex, grid,\n  spacing, sizing, typography, colors, borders, effects, transforms,\n  transitions, tables, SVG, interactivity, media queries, container queries,\n  supports rules, and selector variants.\n- 🎨 Reads Tailwind v4 CSS-first theme tokens from `@theme { ... }`.\n- 🧭 Falls back to Tailwind v4 default theme tokens when no custom theme is\n  provided.\n- 🌈 Matches colors across common CSS formats, including named colors, hex, rgb,\n  and Tailwind v4 OKLCH palette values.\n- 💧 Emits v4 slash opacity classes such as `bg-black/50`.\n- 🔣 Emits v4 CSS variable arbitrary values such as `bg-(--brand)`.\n- 📐 Expands spacing shorthands into stable utilities, for example\n  `padding: 1rem 2rem` becomes `py-4 px-8`.\n- 📏 Converts px spacing values back to the default rem-based spacing scale by\n  default, for example `margin-top: 4px` becomes `mt-1`.\n- 🔌 Supports PostCSS plugins before conversion, such as `postcss-nested`.\n- 🧯 Skips non-convertible declarations by default, with an option to emit\n  arbitrary property classes like `[mask-type:luminance]`.\n\n## 📦 Install\n\n```bash\n# pnpm\npnpm add -D css-to-tailwindcss4\n\n# yarn\nyarn add -D css-to-tailwindcss4\n\n# bun\nbun add -d css-to-tailwindcss4\n\n# npm\nnpm install -D css-to-tailwindcss4\n```\n\n## 🟢 Requirements\n\nRequires Node.js `^20.19.0 || >=22.12.0`.\n\n## 🌊 Tailwind CSS compatibility\n\nGenerated classes target **Tailwind CSS v4.1+** and are verified against\n**v4.3.x**. Some emitted variants (`pointer-coarse:`, `noscript:`,\n`user-valid:`, `details-content:`, `inverted-colors:`) and position names\n(`bg-top-left`) were introduced in v4.1 and do not exist in v4.0.\n\n## 🚀 Usage\n\n```ts\nimport { convertCSS } from 'css-to-tailwindcss4';\n\nconst inputCSS = `\n  .card {\n    display: flex;\n    padding: 1rem 2rem;\n    border-radius: 0.5rem;\n    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);\n    color: #fff;\n    background-color: rgb(0 0 0 / 0.5);\n  }\n\n  .card:hover {\n    background-color: var(--brand);\n  }\n\n  @media (min-width: 48rem) {\n    .card {\n      display: grid;\n    }\n  }\n`;\n\nconst result = await convertCSS(inputCSS, {\n  themeCSS: `\n    @import \"tailwindcss\";\n\n    @theme {\n      --color-brand: #0ea5e9;\n      --spacing: 0.25rem;\n    }\n  `\n});\n\nconsole.log(result.classes);\nconsole.log(result.css);\nconsole.log(result.rules);\n```\n\nConsole output `result.classes`:\n\n```js\n[\n  'flex',\n  'py-4',\n  'px-8',\n  'rounded-lg',\n  'shadow-xs',\n  'text-white',\n  'bg-black/50',\n  'hover:bg-(--brand)',\n  'md:grid'\n];\n```\n\nConsole output `result.css`:\n\n```css\n.card {\n  @apply flex py-4 px-8 rounded-lg shadow-xs text-white bg-black/50 hover:bg-(--brand) md:grid;\n}\n```\n\nConsole output `result.rules`:\n\n```js\n[\n  {\n    selector: '.card',\n    classes: [\n      'flex',\n      'py-4',\n      'px-8',\n      'rounded-lg',\n      'shadow-xs',\n      'text-white',\n      'bg-black/50'\n    ],\n    leftover: [],\n    variants: []\n  },\n  {\n    selector: '.card',\n    classes: ['hover:bg-(--brand)'],\n    leftover: [],\n    variants: ['hover']\n  },\n  {\n    selector: '.card',\n    classes: ['md:grid'],\n    leftover: [],\n    variants: ['md']\n  }\n];\n```\n\n## 🧩 API\n\n### `convertCSS(css, options?)`\n\n```ts\nfunction convertCSS(\n  css: string,\n  options?: ConvertOptions\n): Promise<ConvertResult>;\n```\n\n#### Options\n\n| Option                | Type               | Default     | Description                                                                  |\n| --------------------- | ------------------ | ----------- | ---------------------------------------------------------------------------- |\n| `themeCSS`            | `string`           | v4 defaults | CSS containing Tailwind v4 `@theme { ... }` blocks.                          |\n| `arbitraryProperties` | `boolean`          | `false`     | Convert unknown declarations to arbitrary property classes like `[x:y]`.     |\n| `prefix`              | `string`           | `undefined` | Prefix emitted utilities using v4 prefix order, for example `tw:hover:flex`. |\n| `remInPx`             | `number` \\| `null` | `16`        | Pixel size of `1rem` when matching px values to spacing tokens.              |\n| `postCSSPlugins`      | `AcceptedPlugin[]` | `[]`        | PostCSS plugins to run before conversion.                                    |\n\n#### Result\n\n| Field     | Type              | Description                                                |\n| --------- | ----------------- | ---------------------------------------------------------- |\n| `rules`   | `ConvertedRule[]` | Converted rules in document order.                         |\n| `classes` | `string[]`        | Flat list of every generated Tailwind class.               |\n| `css`     | `string`          | Reconstructed CSS with converted declarations as `@apply`. |\n\n## 🎨 Tailwind v4 handling\n\n### CSS-first theme\n\nTailwind v4 theme values live in CSS variables under `@theme`. The converter\nparses those variables and uses them for reverse lookups:\n\n```ts\nawait convertCSS('.x { color: #ff0066; }', {\n  themeCSS: '@theme { --color-brand-500: #ff0066; }'\n});\n// ['text-brand-500']\n```\n\nSupported theme namespaces include colors, spacing, fonts, text sizes, font\nweights, tracking, leading, breakpoints, containers, radius, shadow,\ninset-shadow, drop-shadow, blur, perspective, aspect, easing, animations,\ntab-size, and zoom.\n\n### Renamed scales\n\nThe default theme uses Tailwind v4 names for renamed scales:\n\n```css\n.x {\n  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);\n  border-radius: 0.125rem;\n}\n```\n\n```js\n['shadow-xs', 'rounded-xs'];\n```\n\n### Slash opacity\n\nAlpha colors emit v4 slash opacity utilities:\n\n```css\n.x {\n  background-color: rgb(0 0 0 / 0.5);\n}\n```\n\n```js\n['bg-black/50'];\n```\n\n### CSS variable arbitrary values\n\nCSS variables use Tailwind v4 parenthesis syntax:\n\n```css\n.x {\n  background-color: var(--brand);\n}\n```\n\n```js\n['bg-(--brand)'];\n```\n\n### Prefix and important\n\nThe converter emits Tailwind v4 ordering for prefix, variants, and important:\n\n```ts\nawait convertCSS('.x:hover { display: flex !important; }', { prefix: 'tw' });\n// ['tw:hover:flex!']\n```\n\n### Variants\n\nThe converter maps supported selectors and at-rules to variant prefixes:\n\n```css\n.button:hover {\n  color: #fff;\n}\n\n@media (prefers-color-scheme: dark) {\n  .button {\n    background-color: #000;\n  }\n}\n\n@container (min-width: 28rem) {\n  .button {\n    display: flex;\n  }\n}\n```\n\n```js\n['hover:text-white', 'dark:bg-black', '@md:flex'];\n```\n\n## 🔧 What's converted\n\n- Layout: `display`, `position`, inset, `float`, `clear`, overflow,\n  visibility, `z-index`, isolation, object fit/position, and box sizing.\n- Flexbox and grid, including alignment, order, basis, gaps, template tracks,\n  auto tracks, placement, and spans.\n- Spacing: padding, margin, scroll padding, scroll margin, negative values,\n  shorthand expansion, axis reduction, and px/rem matching.\n- Sizing: width, height, min/max dimensions, fractions, viewport units,\n  container sizes, and aspect ratio.\n- Typography: color, font family, font size, font weight, line height, letter\n  spacing, text alignment, text decoration, whitespace, word breaking, lists,\n  font smoothing, numeric variants, tab size, content, and font stretch.\n- Colors: token matching, OKLCH matching, alpha slash syntax, CSS variables,\n  current color, transparent, and inherit.\n- Backgrounds: color, image gradients, position, size, repeat, clip, origin,\n  attachment, and blend mode.\n- Borders and outline, including color, width, style, radius, logical corners,\n  and v4 `outline-hidden`.\n- Effects: shadow, inset shadow, opacity, blend modes, filters, and backdrop\n  filters.\n- Transitions, transforms, tables, columns, breaks, scroll snap, SVG fill and\n  stroke, cursor, selection, touch, resize, scroll behavior, appearance,\n  field sizing, color scheme, forced color adjustment, scrollbar width/gutter,\n  backface visibility, and zoom.\n- Variants from `@media`, `@container`, `@supports`, pseudo-classes,\n  pseudo-elements, `not()`, `has()`, `nth-child()`, `[data-*]`, and `[aria-*]`.\n\n## 📄 License\n\n[MIT](./LICENSE)\n\nCopyright (c) 2026-present, [REFINIST](https://github.com/refinist)","users":{}}