Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
joe223 opened this issue Jan 16, 2020 · 5 comments
Closed

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

joe223 opened this issue Jan 16, 2020 · 5 comments

Comments

@joe223
Copy link

joe223 commented Jan 16, 2020

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

This code will break compile process.

@matthew-dean matthew-dean changed the title Can not write css function in less Less doesn't support new math functions (e.g. min, max) Jan 16, 2020
@kbav
Copy link

kbav commented Feb 18, 2020

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)";

@joe223
Copy link
Author

joe223 commented May 6, 2020

@kbav Thanks,that's really helpful!

@WofWca
Copy link

WofWca commented Jul 6, 2020

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)";

@matthew-dean
Copy link
Member

Should be working as of Less 4

@blackmambahk
Copy link

less 4.1.2
this is still generating incompatible types error

min-width: max( percentage(@i * .083333333333), unit(round(@i * 80), px) );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants