question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sass wont let me use css min()

See original GitHub issue

I have css code like this:

–min: 250px; width: min( var(–min), 100%);

Sass breaks with error: Error: “var(–card-min)” is not a number for `min’

I think its trying to use some function called min and not css min. How can i tell it to not do this or ignore sass for this line?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:19 (6 by maintainers)

github_iconTop GitHub Comments

54reactions
daniel-vz7commented, Apr 15, 2021

If anybody is getting this issue you can simply bypass the Sass min() or max() function capitalizing them. It won’t be recognized by Sass compiler, but it’ll continue working on CSS.

e.g. Instead of using font-size: min(1.3vw, 17px); You write it as font-size: Min(1.3vw, 17px);

37reactions
Ariane-Bcommented, Apr 30, 2020

This was annoying me a lot (in Dart Sass 1.26.3), since it was making the use of CSS min/max functions really unreliable, so I created a Sass function to force the CSS functions. Use them if you’d like.

@function css-function( $function, $values... ) {
	@return 
		$function
		+ unquote( '(' )
		+ $values
		+ unquote( ')' )
	;
}

@function css-min( $values... ) {
	@return css-function( min, $values );
}

@function css-max( $values... ) {
	@return css-function( max, $values );
}

@function css-clamp( $values... ) {
	@return css-function( clamp, $values );
}

You might still need to use #{ } interpolation when using Sass variables and CSS variables combined with them though, in some cases, to make sure Sass parses them properly. So:

.my-selector {
  width: css-min( #{ $width-abs }, #{ $width-rel } );
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

When Sass and New CSS Features Collide
This is because Sass has its own min() function, and ignores the CSS min() function. Plus, Sass cannot perform any sort of computation...
Read more >
How to Use Sass with CSS - freeCodeCamp
To do this, the compiler will generate a file with the CSS code. This transformation is called compilation.
Read more >
Sass Basics
The most direct way to make this happen is in your terminal. Once Sass is installed, you can compile your Sass to CSS...
Read more >
min() - CSS: Cascading Style Sheets - MDN Web Docs
Syntax. The min() function takes one or more comma-separated expressions as its parameter, with the smallest (most negative) expression value ...
Read more >
Deprecating Sass for Shopify Themes
css file will be updated with this change. Using these automation tools to compile your .scss files will allow you to access the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found