BEM and Sass, without mixins or functions

Jack Sleight
1 min readJul 14, 2016

To follow up on my previous BEM and Sass post, it’s actually possible to use an even simpler syntax without any mixins or functions at all.

This:

.block {
$b: &;
margin: 1em;
&__element {
color: red;
}
&--modifier {
margin: 2em;
#{$b} {
&__element {
color: blue;
}
}
}
}

Will output this:

.block {
margin: 1em;
}
.block__element {
color: red;
}
.block--modifier {
margin: 2em;
}
.block--modifier .block__element {
color: blue;
}

--

--