How Does One Inherit BEM styles?
everydaysuperpowers.dev·31w
🎨Design Tokens
Preview
Report Post

At work, we follow the BEM methodology in naming our HTML elements and CSS styles. But we’ve been struggling with the best way to inherit styles from similar blocks. As with many things in programming, there’s great documentation to get you started, but the next level is up to you.

From my research, there seems to be three primary behaviors for inheriting styles:

Option 1: Extend all the options

This method expects you to create bite-sized components you will extend in classes:

Option 2: Extend the parent

This method inherits the parent on every option:

Option 3: Extend is evil

It seems there’s a group of developers that thinks @extend is a bad thing. They suggest mixing in components.

What about the next level?

These three …

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help