lessGuards (for writing conditional mixins)


Syntax

  • Mixin with Guards
  • .mixin-name(<arguments>) when <is-negation> (<ref-variable> <operator> <value>)
  • CSS Guards
  • <selector> when <is-negation> (<ref-variable> <operator> <value>)

Parameters

ParameterDetails
argumentsThe variables that are passed to the parametric mixin. Arguments are optional.
is-negationThis indicates whether the guard condition is a not condition or not. For example when not (@type = error) means the mixin will be used whenever the value of @type is not error.
ref-variableThis is the variable whose value determines which mixin's properties should be applied to the element. This is mandatory.
operatorThis is the operator that is used for evaluating the condition. It can be =, >, <, >=, <=. This is not mandatory. When the operator and value is not given, the compiler assumes the condition to be &lt;ref-variable> = true.
valueThe value that is used for evaluating the condition. This is optional but becomes mandatory when an operator is provided.