1.0.4 • Published 6 months ago

bemmy v1.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
6 months ago

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'
1.0.4

6 months ago

1.0.3

10 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago

141.0.0

3 years ago

137.0.0

3 years ago