Less.js: Less doesn't support new math functions (e.g. min, max)

Created on 16 Jan 2020  ·  4Comments  ·  Source: less/less.js

border-width: max(.01rem, 1px);

This code will break compile process.

feature request high priority

Most helpful comment

Note: This is likely also true for the related clamp() function.

A workaround

For anyone coming across this needing a workaround, you can always use LESS' string escaping capabilities to pass along a plain string to the CSS, eg.

border-width: ~"max(.01rem, 1px)";

All 4 comments

Note: This is likely also true for the related clamp() function.

A workaround

For anyone coming across this needing a workaround, you can always use LESS' string escaping capabilities to pass along a plain string to the CSS, eg.

border-width: ~"max(.01rem, 1px)";

@kbav Thanks,that's really helpful!

If you need to use Less variables, e.g. max(@my-var, 1px), you can do

@my-var: .01rem;
--my-var: @my-var;
border-width: ~"max(var(--my-var), 1px)";

Should be working as of Less 4

Was this page helpful?
0 / 5 - 0 ratings