Answer the question
In order to leave comments, you need to log in
How to properly prepare css-modules?
Let's say we have a button class that describes a basic button. But in fact, I will use its descendants, namely different types of buttons: default, primary, danger, etc. Then I will describe them like this:
/* buttons.css */
.primary {
composes: button;
// здесь специфичные стили
}
import buttons from './styles/buttons.css';
innerHTML = `<button class="${buttons.primary}">`;
Answer the question
In order to leave comments, you need to log in
Figured it out myself. As written in this article glenmaddern.com/articles/css-modules - "composition is everything". This means that I misunderstood the method. Before that, I used Yandex BEM in projects. In their version there is a modifier - an additional class for the main class. There is no such thing in CSS modules and each class is separate and is made up of other classes. That is, if I need a regular button, then I use the buttons.default class containing the base style. If you need a regular big one, then buttons.defaultBig.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question