{"name":"tailwind-variants","version":"3.2.0","keywords":["tailwindcss","classes","responsive","variants","styled","styles"],"author":{"name":"Junior Garcia","email":"jrgarciadev@gmail.com"},"license":"MIT","_id":"tailwind-variants@3.2.0","maintainers":[{"name":"juniorgarciadev","email":"jrgarciadev@gmail.com"}],"homepage":"https://github.com/heroui-inc/tailwind-variants#readme","bugs":{"url":"https://github.com/heroui-inc/tailwind-variants/issues"},"dist":{"shasum":"b6e1ab77d0e45822519ce9b4a95171ce32605142","tarball":"http://registry-npm.ywwl.com/tailwind-variants/download/tailwind-variants-3.2.0.tgz","fileCount":18,"integrity":"sha512-JtAWj4pR/ll2J1IqJSe11A12O133UA951m0LGdvfVcX9BImtNFWN2mkyraOD6307ffKDNuQ/PJUJlcP1Lg0NxA==","signatures":[{"sig":"MEUCIQD51TVWDN4tZ7bOIf+7o8FL6hOUwKS8n/h7TTPQppgBmAIgXw0Xpa7cWXQSgHfKy8A7X2fpSmqasL8gugfQXOFL5ik=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":59879,"size":11981,"noattachment":false,"key":"/tailwind-variants/-/tailwind-variants-3.2.0.tgz"},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=16.x","pnpm":">=7.x"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./lite":{"types":"./dist/lite.d.ts","import":"./dist/lite.js","require":"./dist/lite.cjs"},"./utils":{"types":"./dist/utils.d.ts","import":"./dist/utils.js","require":"./dist/utils.cjs"},"./dist/*":"./dist/*","./package.json":"./package.json"},"gitHead":"c19f93d8effe2a3b22e4ca34990b5e7b6cb02e92","scripts":{"dev":"tsup --watch","lint":"eslint . src/**/*.{js,ts}","test":"jest --verbose","build":"tsup && node copy-types.cjs","prepack":"clean-package","release":"bumpp --execute='pnpm run changelog' --all","lint:fix":"eslint --fix . src/**/*.{js,ts}","postpack":"clean-package restore","benchmark":"node benchmark.js","changelog":"conventional-changelog -p angular -i CHANGELOG.md -s --commit-path .","typecheck":"tsc --noEmit","test:watch":"jest --watch --no-verbose","release:check":"pnpm run lint && pnpm run typecheck && pnpm run test && pnpm run build","prepublishOnly":"pnpm run build"},"_npmUser":{"name":"juniorgarciadev","email":"jrgarciadev@gmail.com"},"repository":{"url":"git+https://github.com/heroui-inc/tailwind-variants.git","type":"git"},"_npmVersion":"11.6.2","description":"🦄 Tailwindcss first-class variant API","directories":{},"sideEffects":false,"_nodeVersion":"24.11.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"packageManager":"pnpm@10.14.0","devDependencies":{"jest":"29.7.0","tsup":"8.5.0","bumpp":"10.2.0","eslint":"8.57.0","expect":"29.7.0","postcss":"8.5.6","ts-node":"10.9.2","@swc/cli":"0.5.0","prettier":"3.3.3","@swc/core":"1.9.2","@swc/jest":"0.2.37","benchmark":"2.1.4","typescript":"5.6.3","@types/jest":"29.5.14","@types/node":"22.9.0","tailwindcss":"4.1.11","@swc/helpers":"0.5.15","@jest/globals":"29.7.0","clean-package":"2.2.0","@swc-node/jest":"1.8.12","changelogithub":"13.16.0","@commitlint/cli":"19.5.0","prettier-eslint":"16.3.0","eslint-plugin-jest":"28.9.0","eslint-plugin-node":"11.1.0","prettier-eslint-cli":"8.0.1","eslint-plugin-import":"2.31.0","eslint-plugin-promise":"7.1.0","eslint-config-prettier":"9.1.0","eslint-plugin-prettier":"5.2.1","class-variance-authority":"0.7.0","eslint-config-ts-lambdas":"1.2.3","@typescript-eslint/parser":"8.14.0","conventional-changelog-cli":"5.0.0","@commitlint/config-conventional":"19.5.0","@typescript-eslint/eslint-plugin":"8.14.0","eslint-import-resolver-typescript":"3.6.3"},"peerDependencies":{"tailwindcss":"*","tailwind-merge":">=3.0.0"},"peerDependenciesMeta":{"tailwind-merge":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/tailwind-variants_3.2.0_1763848477908_0.4054602140214829","host":"s3://npm-registry-packages-npm-production"},"readme":"<p align=\"center\">\n  <a href=\"https://tailwind-variants.org\">\n    <img width=\"20%\" src=\".github/assets/isotipo.png\" alt=\"tailwind-variants\" />\n    <h1 align=\"center\">tailwind-variants</h1>\n  </a>\n</p>\n<p align=\"center\">\n  The <em>power</em> of Tailwind combined with a <em>first-class</em> variant API.<br><br>\n  <a href=\"https://www.npmjs.com/package/tailwind-variants\">\n    <img src=\"https://img.shields.io/npm/dm/tailwind-variants.svg?style=flat-round\" alt=\"npm downloads\">\n  </a>\n  <a href=\"https://www.npmjs.com/package/tailwind-variants\">\n    <img alt=\"NPM Version\" src=\"https://badgen.net/npm/v/tailwind-variants\" />\n  </a>\n  <a href=\"https://github.com/heroui-inc/tailwind-variants/blob/main/LICENSE\">\n    <img src=\"https://img.shields.io/npm/l/tailwind-variants?style=flat\" alt=\"License\">\n  </a>\n</p>\n\n## Features\n\n- First-class variant API\n- Slots support\n- Composition support (including multi-extend)\n- Fully typed\n- Framework agnostic\n- Built-in conflict resolution\n- Debugging and tracing (experimental)\n- Tailwind CSS v4 support\n\n## Installation\n\n```bash\nnpm i tailwind-variants\n# or\nyarn add tailwind-variants\n# or\npnpm add tailwind-variants\n```\n\n**Lite:** import from `tailwind-variants/lite` for a smaller bundle without conflict resolution.\n\n**Upgrading?**\n\n- v3 → v4: [migration guide](./.docs/migrations/v3-to-v4.md)\n- v2 → v3: [migration guide](./.docs/migrations/v2-to-v3.md)\n- v1 → v2: [migration guide](./.docs/migrations/v1-to-v2.md)\n\n## Quick Start\n\n```js\nimport { tv } from \"tailwind-variants\";\n\nconst button = tv({\n  base: \"font-medium bg-blue-500 text-white rounded-full active:opacity-80\",\n  variants: {\n    color: {\n      primary: \"bg-blue-500 text-white\",\n      secondary: \"bg-purple-500 text-white\",\n    },\n    size: {\n      sm: \"text-sm\",\n      md: \"text-base\",\n      lg: \"px-4 py-3 text-lg\",\n    },\n  },\n  compoundVariants: [\n    {\n      size: [\"sm\", \"md\"],\n      class: \"px-3 py-1\",\n    },\n  ],\n  defaultVariants: {\n    size: \"md\",\n    color: \"primary\",\n  },\n});\n\nbutton({ size: \"sm\", color: \"secondary\" });\n// => \"font-medium rounded-full active:opacity-80 bg-purple-500 text-white text-sm px-3 py-1\"\n```\n\n> **Note:** Tailwind CSS v4 no longer supports `config.content.transform`, so responsive variants\n> were removed. Add responsive classes to your class names manually if needed.\n\n## Conflict Resolution\n\nConflict resolution is built in. The default entry ships compiled merge tables and a\nsingle-pass engine. One engine serves `tv`, `cn`, and `twMerge`. No extra merge package is\nneeded.\n\n```js\nimport { tv, cn, twMerge, twJoin, clsx } from \"tailwind-variants\";\n\ncn(\"px-2\", \"px-4\", { \"py-1\": true }); // => \"px-4 py-1\"\ntwMerge(\"px-2\", \"px-4\"); // => \"px-4\"\ntv({ base: \"px-2\", variants: { size: { lg: \"px-4\" } } })({ size: \"lg\" }); // => \"px-4\"\n```\n\nRepeated work stays off the render path. `cn` answers calls made with the same string instances\nfrom an argument cache. Recipes keep a pre-merged core per variant selection and cache\n`class` / `className` overrides by text, so a new string with the same text still hits.\n\n### Performance\n\nNumbers come from `pnpm benchmark` (Node 24, median of three rounds). Use them for direction,\nnot as absolute figures.\n\n- Against 3.3.1, `cn()` gains about 3× on join-and-merge and about 2× on unique arbitrary values.\n  On stable arguments both sit in the same band: 3.3.1 already cached by argument identity.\n- Hot `tv()` calls run about 1.6×–2× faster than 3.3.1, and faster than cva on the same recipe.\n- Creating a component is slower than cva. `tv()` normalizes and pre-merges at definition so\n  every call is cheaper.\n\n### Aliasing `tailwind-merge` and `clsx`\n\nThe package exports the same names as `tailwind-merge` (`twMerge`, `twJoin`) and `clsx`\n(`clsx`, also the default export). Alias both packages to it and run one engine.\n\n```js\n// app that already uses tv\nresolve: { alias: { \"tailwind-merge\": \"tailwind-variants\", clsx: \"tailwind-variants\" } }\n\n// merge-only code, without the tv runtime\nresolve: { alias: { \"tailwind-merge\": \"tailwind-variants/merge\", clsx: \"tailwind-variants/merge\" } }\n```\n\nCode that calls `extendTailwindMerge` or `createTailwindMerge` aliases `tailwind-merge` to\n`tailwind-variants/config` instead.\n\nKnown limits:\n\n- Unlabeled `font-[…]` follows Tailwind v4: `font-[Inter]` is a font family, `font-[700]` a\n  weight. Labeled forms (`family-name:`, `weight:`) and CSS-variable forms are unchanged.\n- `cx`, `clsx`, and `twJoin` differ. `cx` normalizes whitespace, keeps a numeric `0`, and\n  accepts objects. `twJoin` joins strings and arrays. `clsx` follows clsx.\n- `experimentalParseClassName` is not supported (see below).\n- `twMerge` takes strings and nested arrays. Object syntax belongs to `cn` and `clsx`.\n- Pick one engine per app. Alias everything here, or use the lite entry with the merger you\n  already ship.\n- `TWMergeConfig` is the plain `{ extend, override, prefix, cacheSize }` shape. It is not\n  generic over class-group ids.\n\n### Custom configuration\n\nCustom utilities need the table compiler, which ships only on `tailwind-variants/config`. That\nentry exports the same API plus `twMergeConfig` on `tv`, `createTV`, and `cnMerge`, and the\nconfig API: `extendTailwindMerge`, `createTailwindMerge`, `createTwMerge`,\n`fromTheme`, `validators`, `mergeConfigs`, `getDefaultConfig`. `extend` appends to the\ndefaults, `override` replaces them.\n\n```ts\nimport { createTV, extendTailwindMerge, tv, type TWMergeConfig } from \"tailwind-variants/config\";\n\nconst twMergeConfig = {\n  extend: {\n    classGroups: {\n      elevation: [\"elevation-low\", \"elevation-high\"],\n    },\n  },\n} satisfies TWMergeConfig;\n\ntv({ base: \"elevation-low\", variants: { raised: { true: \"elevation-high\" } } }, { twMergeConfig });\ncreateTV({ twMergeConfig });\nextendTailwindMerge(twMergeConfig)(\"elevation-low elevation-high\"); // => \"elevation-high\"\n```\n\nEach config compiles to its own tables once. Engines are cached by identity and by structure,\nso a config literal rebuilt on every call still compiles once. `prefix` and `cacheSize` are\nhonored. `experimentalParseClassName` is not: inject a merge function that supports it\nthrough `twMerge`.\n\nThe default entry throws on `twMergeConfig`, so a missed import fails at definition time.\nDisable merging with `{ twMerge: false }` on `tv`, `createTV`, or `cnMerge`.\n\n### Lite build\n\nImport from `tailwind-variants/lite` when the app already has a merger, or needs none. Lite\nships no engine and no tables. It joins, or calls the function you inject.\n\n```ts\nimport { createCN, createTV } from \"tailwind-variants/lite\";\nimport { twMerge } from \"tailwind-variants/merge\";\n\nexport const tv = createTV({ twMerge });\nexport const cn = createCN({ twMerge });\n```\n\nLite also exports a strings-only `clsx` (named and default), like `clsx/lite`. `createTV` does\nnot bind `cn`. `debug` is default-entry only. `twMergeConfig` lives on `tailwind-variants/config`.\n\n## Composition\n\n`extend` merges one or more parent recipes into a child. Pass a single `tv()` result, or a **non-empty**\narray merged left-to-right (child options win last).\n\n```ts\nimport { tv } from \"tailwind-variants\";\n\nconst focusable = tv({ base: \"focus-visible:ring-2\" });\nconst animated = tv({ base: \"transition-all duration-150\" });\n\nconst button = tv({\n  extend: [focusable, animated],\n  base: \"inline-flex items-center\",\n});\n\n// Single parent still works:\nconst iconButton = tv({ extend: button, base: \"gap-2\" });\n```\n\nVariants, slots, defaults, and compounds are deep-merged. If two recipes share a variant key that\nshould stay separate, call them individually and join with `cx` / `cn` instead.\n\n## Debugging (experimental)\n\nEnable `debug: true` to log how a recipe resolves classes and which ones the merger dropped.\nOutput appears in the browser console only.\n\n```ts\nimport { tv } from \"tailwind-variants\";\n\nconst button = tv(\n  {\n    base: \"inline-flex rounded bg-red-500 px-2\",\n    variants: {\n      color: { primary: \"bg-blue-600 text-white\" },\n      size: { sm: \"text-sm px-2\", lg: \"text-lg px-6\" },\n    },\n    defaultVariants: { size: \"sm\" },\n  },\n  { debug: true },\n);\n\nbutton({ color: \"primary\", size: \"lg\" });\n```\n\nIn production builds the debug path is fully tree-shaken via `process.env.NODE_ENV` — no logging\ncode, no overhead, and recipe behavior remains identical. The `/lite` entry does not support debug.\n\n## Utility Functions\n\n| Function  | Behavior                                             |\n| --------- | ---------------------------------------------------- |\n| `cx`      | Concatenate class names (no merging)                 |\n| `cn`      | Concatenate and merge with the default config        |\n| `cnMerge` | Concatenate and merge, with optional per-call config |\n\nOn `/lite`, `cn` only joins. Use `createCN({ twMerge })` to bind a merger.\n\n```js\nimport { cx, cn, cnMerge } from \"tailwind-variants\";\n\ncx(\"px-2\", \"px-4\"); // => \"px-2 px-4\"\ncn(\"px-2\", \"px-4\"); // => \"px-4\"\ncnMerge(\"px-2\", \"px-4\")({ twMerge: false }); // => \"px-2 px-4\"\n```\n\n`cn` follows `clsx` for falsy values: `cn(\"foo\", 0)` is `\"foo\"`, while a lone `cn(0)` is `\"0\"`.\n`cx` keeps `0` in every position. See the [v3 to v4 migration guide](.docs/migrations/v3-to-v4.md).\n\nThese utilities — and `tv()` results, including slot functions — always return a `string`; when no\nclasses remain, the result is an empty string, matching common class name utilities.\n\n## Documentation\n\nFor full documentation, visit [tailwind-variants.org](https://tailwind-variants.org).\n\n## Acknowledgements\n\n- [**cva**](https://github.com/joe-bell/cva) ([Joe Bell](https://github.com/joe-bell))\n  This project started as an extension of Joe's work on `cva` — a great tool for generating variants\n  for a single element with Tailwind CSS. Big shoutout to [Joe Bell](https://github.com/joe-bell) and\n  [contributors](https://github.com/joe-bell/cva/graphs/contributors)! If you don't need the\n  **Tailwind Variants** features listed\n  [here](https://www.tailwind-variants.org/docs/comparison), we recommend `cva`.\n\n- [**Stitches**](https://stitches.dev/) ([Modulz](https://modulz.app))\n  The pioneers of the `variants` API movement. Immense thanks to [Modulz](https://modulz.app) for\n  their work on Stitches and the community around it.\n\n- [**shadcn-ui/cn**](https://github.com/shadcn-ui/cn) ([shadcn](https://github.com/shadcn)),\n  [**tailwind-merge**](https://github.com/dcastil/tailwind-merge) ([Dany Castillo](https://github.com/dcastil)),\n  [**cnfast**](https://github.com/aidenybai/cnfast) ([Aiden Bai](https://github.com/aidenybai)), and\n  [**clsx**](https://github.com/lukeed/clsx) ([Luke Edwards](https://github.com/lukeed))\n  The merge engine is a snapshot of `cn`, with `tailwind-merge`'s conflict rules, `clsx`'s\n  argument semantics, and an argument cache in the spirit of `cnfast`. All four are MIT\n  licensed. See [LICENSE](./LICENSE) and the linked repositories.\n\n## Community\n\nWe're excited to see the community adopt HeroUI, raise issues, and provide feedback. Whether it's a\nfeature request, bug report, or a project to showcase, please get involved!\n\n- [Discord](https://discord.gg/9b6yyZKmH4)\n- [Twitter](https://twitter.com/getnextui)\n- [GitHub Discussions](https://github.com/heroui-inc/tailwind-variants/discussions)\n\n## Contributing\n\nContributions are always welcome!\n\n- [Contributing guidelines](./CONTRIBUTING.md)\n- [Code of conduct](./CODE_OF_CONDUCT.md)\n- [Security policy](./SECURITY.md)\n\n## Authors\n\n- Junior Garcia ([@jrgarciadev](https://github.com/jrgarciadev))\n- Tianen Pang ([@tianenpang](https://github.com/tianenpang))\n\n## License\n\nLicensed under the [MIT License](./LICENSE).\n","publish_time":1763848478135,"_cnpm_publish_time":1763848478135,"dist-tags":{"dev":"0.0.17-dev.1","latest":"1.0.0"}}