Reputation: 23
I am trying to have a LESS mixin use a default value if a variable is not set but my code always uses the default value. I am trying:
@color : red;
.mixin (@color : blue)
{
color: @color;
}
.block {.mixin()}
and I am getting blue. In this instance, I want it to be red. Is there another way to do this? Am I missing something. Thanks in advance.
Upvotes: 2
Views: 2254
Reputation: 13354
Your last line you'll want to pass in the color you want, in this case for red, it's defined as @color
globally:
.block {.mixin(@color)}
Without passing in a color, the parameter will be the default blue as defined in the .mixin
definition.
Upvotes: 2