2.0.0 ā€¢ Published 10 months ago

mxcn v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

mxcn

mxcn

DOWNLOADS Node.js CLI Learn VSCode Sponsor Follow @MrAhmadAwais on Twitter

172-byte utility library to use bothclsx and tailwind-merge in one go. Where class merging becomes a seamless dance, leaving style conflicts in the dust!

  • šŸ“¦ Use clsx and tailwind-merge in one go
  • šŸ§æ Fully typed, built-in TypeScript declarations
  • šŸŽ›ļø Works in modern browsers & Node >=12
  • šŸŽ–ļø This module is available in three formats:
  • šŸ“Ÿ ES Module: dist/index.js
  • šŸ“¼ CommonJS: dist/index.cjs
  • šŸŒ UMD: dist/index.global.js

šŸ“Ÿ

Install

npm i mxcn

āš™ļø

Usage

// Note: I called it `cn` as in className.
// Use ESM `import` statement syntax for ESM lib.
import cn from 'mxcn';
import { cn } from 'mxcn'; // Or named import.

// OR use CommonJS `require` syntax for CommonJS lib.
const cn = require('mxcn');

// Basic usage in React.
<div className={cn('custom class or tailwind px-2 py-3 flex')} />

// Example: Combined, any example of tailwind-merge or clsx works.
cn('px-2 py-1 bg-red hover:bg-dark-red', null, true && 'p-3 bg-[#B91C1C]')
//=> 'hover:bg-dark-red p-3 bg-[#B91C1C]'

// Example: tailwind-merge
cn('px-2 py-1 bg-red hover:bg-dark-red', 'p-3 bg-[#B91C1C]')
//=> 'hover:bg-dark-red p-3 bg-[#B91C1C]'
// Why? px-2 and py-1 are removed because of p-3 that came afterwards.

// Example: clsx
// Strings (variadic)
cn('foo', true && 'bar', 'baz')
//=> 'foo bar baz'

// Objects
cn({ foo:true, bar:false, baz:isTrue() })
//=> 'foo baz'

// Objects (variadic)
cn({ foo:true }, { bar:false }, null, { '--foobar':'hello' })
//=> 'foo --foobar'

// Arrays
cn(['foo', 0, false, 'bar'])
//=> 'foo bar'

// Arrays (variadic)
cn(['foo'], ['', 0, false, 'bar'], [['baz', [['hello'], 'there']]])
//=> 'foo bar baz hello there'

// The famous Kitchen sink (with nesting)
cn('foo', [1 && 'bar', { baz:false, bat:null }, ['hello', ['world']]], 'cya')
//=> 'foo bar hello world cya'

For more please check the docs of clsx and tailwind-merge. Cheers!

šŸ“

Changelog

āÆ Read the changelog here ā†’

KEY: šŸ“¦ NEW, šŸ‘Œ IMPROVE, šŸ› FIX, šŸ“– DOC, šŸš€ RELEASE, and šŸ¤– TEST

I use Emoji-log, you should try it and simplify your git commits.

šŸ“ƒ

License & Conduct

šŸ™Œ

Connect

āš™ļø

Course Recommendation

NodeCLI.com ā€” Learn to build Node.js CLI Automation

Node CLI Automation development ā€” without wasting a thousand hours

After building hundreds of developer automation tools used by millions of developers, I am teaching exactly how you can do it yourself with minimum effective effort. Learn to build Node.js & JavaScript-based CLI (Command Line Interface) apps & npm packages. Automate the grunt work, do more in less time, impress your manager, make more salary, and help the community. I'm sharing it all in this step-by-step 100-videos course.

Node CLI Course

šŸ‘Œ

Sponsor

I (Ahmad Awais) and my incredible wife (Maedah Batool) are two engineers who fell in love with open source and then with each other. You can read more about me here. If you or your company use any of my projects or like what Iā€™m doing then consider backing me. I'm in this for the long run. An open-source developer advocate.

Sponsor Awais

āÆāÆ Professional Development Courses ā†“

Node CLI Course VSCode Course Node.js Course

2.0.0

10 months ago

1.3.10

11 months ago

1.3.9

11 months ago

1.3.8

11 months ago

1.3.7

11 months ago

1.3.6

11 months ago

1.3.5

11 months ago

1.3.4

11 months ago

1.3.3

11 months ago

1.3.2

11 months ago

1.3.1

11 months ago

1.3.0

11 months ago

1.2.3

11 months ago

1.2.2

11 months ago

1.2.1

11 months ago

1.2.0

11 months ago

1.1.0

11 months ago

1.0.0

11 months ago

0.0.1

11 months ago