@match
Choose a value by condition: @match(x = y, #000, #fff) is black on the diagonal and white elsewhere.
Syntax
- @match(<condition>, <value> [, <fallback>])
- @match(<c1>, <v1>, <c2>, <v2>, ..., <fallback>)
- condition
-
An expression over the cell variables
x,y,i,X,Y,I,z,Z,dx,dy,drand the others, plusn,nx,nyandNinside a@msequence. - value
- Returned when the condition is true. With several pairs the first true condition wins.
- fallback
- Returned when no condition is true. Empty if omitted.
Inside $() the same idea is
match(condition, value, fallback), with only one pair.
Examples
@grid: 5 / 60vmin _1px;
background: @match(i > 12, #e6437d, #000); @grid: 7 / 60vmin _1px;
background: #000;
color: #fff;
@content: @match(x = y, '✓', ''); Several branches:
@grid: 15 / 60vmin _1px;
background: @match(
dr < 3, #000,
dr < 5, #e6437d,
dr < 7, #ebbf4d,
#eee
); Inside a sequence:
@grid: 1 / 60vmin;
background: conic-gradient(
@m12(@match(n % 2 = 0, #000, #fff) 0 @n(*30deg))
);