Let's say I have the following CSS for a generic list component, using BEM and SCSS:
.list {
&__item {
&:not(:last-child) {
margin-right: .3em;
}
}
}
I want to add a modifier that can make the list vertical, like so:
.list--vertical {
display: flex;
flex-direction: column;
}
My problem arises when I think about the margin for list__item elements. For vertical lists, I want my margin on the bottom, not right of each item. If I understood BEM correctly, I cannot modify the style of list__item based on the modifer of list, is that correct?
To be more precise, this is what I want to do:
.list--vertical {
display: flex;
flex-direction: column;
.list__item {
&:not(:last-child) {
margin-bottom: .3em;
margin-right: 0;
}
}
}
What is the accepted way of dealing with this using BEM? Another modifier for list__item that handles the margin? Another block entirely for vertical lists?