Answer the question
In order to leave comments, you need to log in
When to use mixes in BEM and when to use modifiers?
I have a basic card like this:
<div class="card">
<img src="" alt="" class="card__icon">
<div class="card__title"></div>
<div class="card__desc"></div>
</div>
.card {
&__icon {
width: var(--icon-width, 20px);
}
&__title {
margin-bottom: var(--margin-title, 10px);
}
}
// та же разметка за исключением класса
<div class="news-card card">
<img src="" alt="" class="card__icon">
<div class="card__title"></div>
<div class="card__desc"></div>
</div>
.news-card {
--icon-width: 10px;
--margin-title: 5px;
}
Answer the question
In order to leave comments, you need to log in
Open any WordPress site and see how the video-container CSS class is implemented. In WP, the iframe is "wrapped" in a div with the video-container class. Here is the WP site
Usually a certain UI Kit is formed, and at most sometimes it is necessary to modify the display of the block in some cases. Look at what you have with the design, maybe you are trying to fit one block to a million different tasks, while these should be different blocks.
In general, if you're adjusting a style on a case-by-case basis, it's a modifier. If you have a lot of them - that's fine too (in terms of class placement), but note why there are a lot of them, it's not quite typical to have 20-40 different modifiers for one block on different pages.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question