Skip to content

SimonArdrey/bem-block

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bem-block

Build Status

BEM CSS class names generator for use in React

Created a simple BEM library because all the string concatenation was driving me crazy. BEM info: http://getbem.com/naming/

Install

npm install bem-block --save

Usage

import block from 'bem-block'; or var block = require('bem-block');

Example

const myBlock = block('my-block', 'some-modifier', 'another-modifier');
// or
const myBlock = block('my-block', ['some-modifier', 'another-modifier']);
// or
const myBlock = block('my-block', {
  'some-modifier': true,
  'another-modifier': false,
});

Then in JSX

<div className={myBlock()}>
  <div className={myBlock('some-element', 'and-a-modifier')}></div>
</div>

Will produce:

<div class="my-block my-block--some-modifier">
  <div class="my-block__some-element my-block__some-element--and-a-modifier"></div>
</div>

About

BEM CSS class names generator for use in React

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published