Prevent variable color name to be converted to hexadecimal in smaller class names

I want to use a variable that will hold the name of the color (red, blue, green, etc.) and define some class style rules. For example:

.mixins-common-components(@colorName, @backgroundColor, @textColor){
  .btn{
     &.@{colorName}{
         color: @textColor;
         background-color: @backgroundColor;
         border-color: "";
     }
  }
}

.mixins-common-components(blue, #3781f7, #4b8df8);

      

This will return me something like this:

.btn.#0000ff {
  color: #4b8df8;
  background-color: #3781f7;
  border-color: "";
}

      

Well, as the .btn picture shows, this is not normal. I would like to show it like this:

 .btn.blue{ ... }

      

I notice that less will automatically convert the color name to a HEX value. I tried to use quotes as well, but that seems to be a bad solution too. Is there a solution to fix this in an elegant way?

Thank.

+3
css css3 less


source to share


No one has answered this question yet

See similar questions:

1
lesser mixin name is graded by color / color

or similar:

1156
What characters are valid in CSS class names / selectors?
296
CSS3 border-radius property and crash-collapse: crash does not mix. How do I use the bounding radius to create a collapsed table with rounded corners?
105
How can I convert HEX color to rgba using Less compiler?
4
Beveled corner on rounded button
4
Is there a bug in safari when calculating percentage width?
2
LESS css: trying to use red, green and blue functions to get rgb values ​​and then paste into gradient
1
css code-duplication sophistically with LESS (or sass)
1
What is the most efficient color change method for multiple similar elements in LESS?
1
Change border color of submit button after clicking on it, CSS, HTML
0
How can I get individual color components (red, blue, green) from rgb format using javascript?



All Articles
Loading...
X
Show
Funny
Dev
Pics