Mixins: passing argument for 3rd parameter only

I am new to Less and have a problem about this ...

I have this code

// Mixin

.border(@width: 1px, @type: solid, @color: #fff){
      border: @arguments;
}

// implementation

.class{
     .border(#ff0000);
}

Is it possible to change only the @color parameter in the border mixin. When I set the value in @arguments, this does not give me the opportunity to change one of the parameters. Maybe there is a smarter way to code this ... Thanks

+4
source share
1 answer

Just use Named Parameters :

.class {
      .border(@color: #ff0000);
}
+3
source

Source: https://habr.com/ru/post/1546440/


All Articles