Skip to content

Conversation

@jrgarciadev
Copy link
Member

@jrgarciadev jrgarciadev commented Nov 22, 2025

Closes: #268

Description

This PR makes twMerge default to true in the cn function, allowing users to call cn('bg-red-500', 'text-white') without explicitly passing { twMerge: true }. Users can still disable merging by passing { twMerge: false }.

Changes:

  • Updated cn function in src/tw-merge.js to default twMerge to true when config is undefined or twMerge is not specified
  • Added comprehensive tests in src/__tests__/cn.test.ts to verify default behavior and backward compatibility
  • Added JSDoc documentation for cx, cn, tv, and createTV functions in src/index.d.ts
  • Fixed type definition in src/lite.d.ts to match implementation

Before:

cn('bg-red-500', 'bg-blue-500')({ twMerge: true }) // Required

After:

cn('bg-red-500', 'bg-blue-500')() // twMerge defaults to true
cn('bg-red-500', 'bg-blue-500')({ twMerge: false }) // Can still disable### Additional context
  • All existing tests pass, ensuring backward compatibility
  • TypeScript type checking passes
  • The change is minimal and follows the existing code patterns
  • Documentation has been added to improve developer experience

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Follow the Style Guide.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).

@jrgarciadev jrgarciadev merged commit 1659aa7 into main Nov 22, 2025
4 checks passed
@jrgarciadev jrgarciadev deleted the fix/268 branch November 22, 2025 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docs are incorrect in showing how to call CN function

2 participants