1.0.0 • Published 8 months ago
cls-bem v1.0.0
cls-bem
BEM class names utility
Usage
Create a block scope
import { bem } from "cls-bem";
const cls = bem("my-block");Apply block class name
cls(); // my-blockApply element class name
cls("__element"); // my-block__elementApply modifier class name
cls("--modifier"); // my-block my-block--modifierApply element and modifier class names
cls("__element", "--modifier"); // my-block__element my-block__element--modifierExample
const cls = bem("user-card");
<div class={cls()}>
<img class={cls("__avatar")} />
<span class={cls("__name", isOnline && "--online")}></span>
</div>;.user-card {
&__avatar {
}
&__name {
&--online {
}
}
}.user-card {
}
.user-card__avatar {
}
.user-card__name {
}
.user-card__name--online {
}1.0.0
8 months ago