I'm using SASS's handy ampersand notation to add BEM-style modifiers to my classes:
.box {
display: inline-block;
width: 100px;
height: 100px;
background: magenta;
&--selected {
background: cyan;
}
}
I'm exploring the possibility of only having to apply a single class to my elements (ex: <div class="box--selected">...</div>
as opposed to <div class="box box--selected">...</div>
). I'd like to avoid using @extend
, it casts too wide a net. Currently I'm using mixins, which are good, but a little verbose to use for every single class with a modifier.
What I'd really like to do is get &--selected
to inherit all the properties from the parent enclosure, and only from the parent enclosure - ie ignore any other class definitions of .box
that careless devs may have inserted.