32
loading...
This website collects cookies to deliver better user experience
block__element--modifier
block
represents the wrapping element of your component, there is only one per component.element
is any element within your block.modifier
is used to change appearance, behaviour or state.rebem-classname
that does the job for you.Install the ‘rebem-classname’ package
npm install rebem-classname
Use stringify to generate BEM class names in your component:
import { stringify } from 'rebem-classname';
import './Component.style.css';
function Component() {
const bem = stringify({ block: 'block', elem: 'elem', mods: { mod: true } });
return <div className={bem}>I'm using BEM!</div>;
}
export default Component;
<div class="block__elem block__elem_mod">I'm using BEM!</div>