Alexander Lomia Alexander Lomia - 4 years ago 121
Sass (Sass) Question

BEM - applying contextual styles to the block inside another block

Suppose we have

.container
and
.button
blocks:



<div class="container">
<!-- some html -->
<a class="button">A Marvelous button</a>
</div>


How should we approach styling of the
.button
block exclusively in
.container
's context? Should we still create a
.button--modifier
?

Answer Source

In this case if the button will be (re)used elsewhere, within different sections then I would say style it .button--modifier. Check out the atomic design pattern (http://patternlab.io/), in this case a button would be an atom and the container likely a molecule. I think it is a good idea to style all reusable atoms in a .atom--modifier way but it would be good to hear other's views on this

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download