1

How can I translate the following conditional to LESS?

.mixin(@width) {
    width: (!@width ? auto : @width);
}

Results should be like:

[no value is passed]
LESS: .mixin();
CSS: width: auto;

[value is passed]
LESS: .mixin(200px);
CSS: width: 200px;
Harry
  • 87,580
  • 25
  • 202
  • 214
pilau
  • 6,635
  • 4
  • 56
  • 69

1 Answers1

4

You can use default parameter values to accomplish this:

.mixin(@width: auto) {
  width: @width;
}
paul
  • 1,201
  • 12
  • 9