Skip to content

Releases: heroui-inc/tailwind-variants

v3.2.2

22 Nov 22:45

Choose a tag to compare

No significant changes

Β Β Β Β View changes on GitHub

v3.2.1

22 Nov 22:10

Choose a tag to compare

   🐞 Bug Fixes

Β Β Β Β View changes on GitHub

v3.2.0

22 Nov 21:54

Choose a tag to compare

Β Β Β πŸš€ Features

   🐞 Bug Fixes

Β Β Β Β View changes on GitHub

v3.1.1

08 Sep 23:33

Choose a tag to compare

   🐞 Bug Fixes

  • Use 'type' for type-only imports and specify file extensions Β -Β  by @tmkx in #272 (58aa7)
Β Β Β Β View changes on GitHub

v3.1.0

25 Aug 19:38

Choose a tag to compare

Β Β Β πŸš€ Features

Β Β Β Β View changes on GitHub

v3.0.0

24 Aug 21:06

Choose a tag to compare

What's new?

Β Β Β πŸš€ Features

Resolves #262, resolves #259, resolves #258, resolves #246

Problem with v2

#262, #246: slot names that match JS String prototype methods cause cnBase to produce corrupted class output.

#259: since cnBase no longer goes through twMerge, template strings aren’t formatted correctly.

#258: lazy-loading tailwind-merge prevents some classes from merging on the first render, but after HMR triggers.

Solution

#258: instead of using lazy-loading, we could split tv into two versions, the lite version no longer imports tailwind-merge, while the original version keeps a static import of tailwind-merge. This avoids the first-render merge issue caused by lazy-loading. An alternative would be making tv async to wait for lazy-loading, but that introduces a larger breaking change and worse dx.

#262, #246, #258: cnBase was enhanced to support functionality similar to classnames / clsx, it now properly filters and handles various input types and formats the final result (e.g., removing extra spaces or newlines), which was previously handled by twMerge.

Technical Details

  • Extracted tailwind-merge and related config logic into tw-merge.js, state.js, package exports (., ./lite) support tree-shaking during build.
  • Original and lite versions share the same core code and type declarations.
  • Moved cnBase to utils and renamed it to cn.
  • Lite version exports cn / cnBase without any tw-merge logic; original (index) exports retain the original behavior.
  • Tailwind merge's cache state is now maintained in state.js.

Testing

  • Covered utils/cn with comprehensive tests.
  • Used describe.each to run tests for both original and lite versions.

Breaking Changes 🚨

⚠️ Only affects users who do not use tailwind-merge, they should import from tailwind-variants/lite, for example:

import { createTV, tv, cn, cnBase } from "tailwind-variants/lite";

⚠️ In the lite version, createTV, tv, cn no longer accept config parameters (i.e., tailwind-merge config).

Version

Due to breaking changes, this will be a major release from 2.1.0 to 3.0.0.

Β Β Β Β View changes on GitHub

v2.1.0

31 Jul 15:26

Choose a tag to compare

Β Β Β πŸš€ Features

Β Β Β Β View changes on GitHub

v2.0.1

28 Jul 16:23

Choose a tag to compare

  • Update tsup configuration to enable cleaning and minification
Β Β Β Β View changes on GitHub

Full Changelog: v2.0.0...v2.0.1

v2.0.0

27 Jul 19:47

Choose a tag to compare

Breaking Changes 🚨

tailwind-merge is now an optional peer dependency

In v2, we've made tailwind-merge an optional peer dependency to reduce bundle size for users who don't need Tailwind CSS conflict resolution.

What changed?

  • tailwind-merge is no longer bundled with tailwind-variants
  • Users who want conflict resolution must install it separately
  • Users who don't need conflict resolution can save ~3KB in bundle size

Migration Steps

If you use the default configuration with twMerge: true (conflict resolution enabled):

# npm
npm install tailwind-merge

# yarn
yarn add tailwind-merge

# pnpm
pnpm add tailwind-merge

If you don't need conflict resolution, disable it in your config:

const button = tv(
  {
    base: "px-4 py-2 rounded",
    variants: {
      color: {
        primary: "bg-blue-500 text-white",
        secondary: "bg-gray-500 text-white",
      },
    },
  },
  {
    twMerge: false, // Disable conflict resolution
  },
);

Performance Improvements

v2 also includes significant performance optimizations:

  • 37-62% faster for most operations πŸš€
  • Optimized object creation and array operations
  • Reduced function call overhead
  • Better memory usage

All existing APIs remain the same, so no code changes are required beyond the tailwind-merge installation.

v1.0.0

08 Mar 16:20

Choose a tag to compare

What's Changed

Breaking change

  • The responsiveVariants option has been removed.
  • withTv has been removed.

New Contributors

Full Changelog: v0.3.1...v1.0.0