ClassName ·

Tiny helper for building CSS classes with BEM methodology.
Install
npm i -S @bem-react/classname
Usage
import { cn } from '@bem-react/classname';
const cat = cn('Cat');
cat();
cat({ size: 'm' });
cat('Tail');
cat('Tail', { length: 'small' });
const dogPaw = cn('Dog', 'Paw');
dogPaw();
dogPaw({ color: 'black', exists: true });
Configure
By default classname
uses React naming preset. But it's possible to use any.
import { withNaming } from '@bem-react/classname';
const cn = withNaming({ n: 'ns-', e: '__', m: '_', v: '_' });
cn('block', 'elem')({ theme: 'default' });