Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Utility function to use both `clsx` and `tailwind-merge` in one go. Where class merging becomes a seamless dance, leaving style conflicts in the dust!
Utility function to use both
clsx
andtailwind-merge
in one go. Where class merging becomes a seamless dance, leaving style conflicts in the dust!
clsx
and tailwind-merge
in one godist/index.js
dist/index.cjs
dist/index.global.js
npm i mxcn
// 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
andtailwind-merge
. Cheers!
KEY: 📦 NEW
, 👌 IMPROVE
, 🐛 FIX
, 📖 DOC
, 🚀 RELEASE
, and 🤖 TEST
I use Emoji-log, you should try it and simplify your git commits.
(follow) To get #OneDevMinute development tips
(connect) On LinkedIn, you know what to do here
(subscribe) Tech talks & #OneDevMinute videos
(read) In-depth & long-form technical articles
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.
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.
❯❯ Professional Development Courses ↓
RELEASE: 1.3.4
🐛 Log
8e6c92e
📖 Changelog
ce4e2b5
📖 Changelog
f23fe81
📖 Changelog
3eaa8e0
📖 Changelog
36158a4
📖 Changelog
b931dd5
📖 Changelog
9808219
📖 Lingo
f4a196a
<br> <br> <img src="https://raw.githubusercontent.com/ahmadawais/stuff/master/changelog/dark-hr.png#gh-dark-mode-only" alt="hr" /> <img src="https://raw.githubusercontent.com/ahmadawais/stuff/master/changelog/light-hr.png#gh-light-mode-only" alt="hr" /> <br>📖 Changelog
3305e7c
FAQs
Utility function to use both `clsx` and `tailwind-merge` in one go. Where class merging becomes a seamless dance, leaving style conflicts in the dust!
We found that mxcn demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.