KittyGiraudel/ama

Use of Sass `&` for class concatenation

Closed this issue · 1 comments

Hi Hugo,

What do you think about & for class concatenation and why you don't use it in your projects?

.media {
  // Styles for `.media` block

  &__img {
    // Styles for `.media__image` element

    &--full {
      // Styles for `.media__image--full` modified element
    }
  }

  &--new {
    // Styles for `.media--new` modifier
  }
}

Cheers

Hey there!

I’m strongly against nesting in Sass (or any other flavour of CSS for that matter) as I don’t think it solves any issue. This is pure syntactic sugar that personally taste very bitter if you ask me.

I wrote about this many times in the past, quite in-depth in this article: https://www.sitepoint.com/beware-selector-nesting-sass/.

I hope it helps. :)