'OOCSS' methods such as SMACSS and BEM prescribe naming your selectors as such:
.room {} /* A base Module (BEM: block) */
.room__door {} /* A descendant element of the `.room` Module (BEM: element) */
.room--bedroom {} /* A different Sub-Module or 'version' of our base Module (BEM: modifier) */
… but besides modules and sub-modules we have 'state' based selectors: e.g. .is-empty {}
(SMACSS).
To me it seems BEM approaches these state-selectors as 'Modifiers' and thus couples the state-selector to the object (block or element): .room--empty {}
.
SMACSS does not seem to do this and also suggests using state-selectors for JS. I like the convention to start state-selector names with .is-
.
I think I like the BEM approach better though: couple the state-rules to objects (not .is-empty
but .is-room-empty
) and do not use these selectors with JS (use .js-
selectors and/or @data
instead).