JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q30272F
  • License Apache-2.0

Resolve multiple and dynamic class names.

Package Exports

  • cncn

Readme

cncn

  • Tailwind-Merge and CLSX NPM shortcut.
  • NPM CNCN
// Download
npm i cncn

// commonjs
const cn = require('cncn');
// esm
import cn from 'cncn';

// Examples
// class variables
const baseClasses = 'bg-blue-500 text-white';
const isActive = false;

// If classes clash, the last one wins.
cn('text-black', baseClasses, { 'bg-red-500': !isActive }); // 'text-white bg-red-500'
cn('text-black', baseClasses, !isActive && 'bg-red-500'); // 'text-white bg-red-500'

// Exported types
import { type CV, type CN } from 'cncn';
// CV shorthand for clsx type ClassValue. 'string | number | bigint | boolean | ClassArray | ClassDictionary | null | undefined'
// CN shorthand for type cn function. (...inputs: ClassValue[]) => string