Andrew Howard
Andrew Howard

Reputation: 3072

Use a variable in a class

Is there a way to use a variable based on a parent class?

I wish to use this color variable:

$primaryColor: #a59062;

And I'm using it fine like this:

button
{
background: $primaryColor;
}

But how can I change the $primaryColor value if a parent class should be over it? I tried this but it doesn't work:

$primaryColor: #a59062;

.hospitalityMode {
  $primaryColor: #4892C8;
}

Upvotes: 0

Views: 13

Answers (1)

user2652134
user2652134

Reputation:

If you want button inside .hospitalityMode to be different.

button
{
  background: $primaryColor;

  .hospitalityMode & {
    background: #4892C8;
  }

}

Upvotes: 1

Related Questions