bemmy
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

bemmy

Dependency-free utility to compose CSS classnames following the BEM convention.

Installation

npm install bemmy

Usage

Basic examples

import bemmy from 'bemmy';

const bem = bemmy('block');

bem();
// -> 'block'

bem('element');
// -> 'block__element'

bem(null, 'modifier');
// -> 'block block--modifier'

bem('element', 'modifier');
// -> 'block__element block__element--modifier'

// modifier object
bem('element', { tall: true, green: true });
// -> 'block__element block__element--tall block__element--green'

// modifier array
bem('element', ['tall', 'green']);
// -> 'block__element block__element--tall block__element--green'

// dynamic modifiers
const props = {
  tall: false,
  wide: true,
  custom: 1 > 2, // some expression that resolves to true or false
};
bem('element', props);
// -> 'block__element block__element--wide'

// additional classes
bem(null, null, 'some-class', 'another-class');
// -> 'block some-class another-class'

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.467latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.467
1.0.357
1.0.157
1.0.058

Package Sidebar

Install

npm i bemmy

Weekly Downloads

205

Version

1.0.4

License

ISC

Unpacked Size

10.8 kB

Total Files

5

Last publish

Collaborators

  • motogoozy