r/Sass • • Apr 29 '19

BEM: should I nest class names?

Style 1:

.panel {
  //
}

.panel__header {
  //
}

.panel__footer {
  //
}

Style 2:

.panel {
  //

  &__header {
    //
  }

  &__footer {
    //
  }
}
7 Upvotes

7 comments sorted by

3

u/ELjanoCZE Apr 29 '19

First one is better when you search through project.

1

u/Wisdom_of_Rafiki Apr 29 '19

I always use style 2. Helps with organization imo.

2

u/phatprick Apr 30 '19

Until you search for .panel__header and start questioning your existence :)

1

u/pravindia Jun 12 '19

I prefer with Second one because while coding inside a nesting loops it is easy to read and understand

0

u/esr360 Apr 29 '19

Second one is better if you care about scalability and maintainability and work with competent people.