How can I define in LESS an element that has a class of class=“btn btn-primary”

I have tried all different combinations but don’t seem to be able to get it right. Can someone help by telling me how I can define this in less given the starting point of:

.btn { }

solution

You could use the LESS parent selector, &, to reference the parent selector.

.btn {
  &.btn-primary {
      color: red;
  }
}

In doing so, you are essentially selecting .btn elements that also have the class .btn-primary.

The above LESS will compile to the following:

.btn.btn-primary {
  color: red;
}