suryanaga
suryanaga

Reputation: 4002

Sass mixin that takes a class as it's argument

I'm trying to create a Sass mixin that takes a class as it's argument:

@mixin myMixin($el){
  > #{$el}{
    background: white;
  }
}

.myClass1{
  @include myMixin(div);
}

The above code works fine. I.e., elements are accepted.

But this calls an error:

.myClass1{
  @include myMixin(.myClass);
}

I've tried wrapping it in quotes and #{} but still no dice.

Curiously, the * selector also does not work.

Upvotes: 10

Views: 4575

Answers (1)

cimmanon
cimmanon

Reputation: 68319

You need to quote your class:

.myClass1{
  @include myMixin(".myClass");
}

Upvotes: 10

Related Questions