math.strip-unit()
The math.strip-unit()
function strips the unit from a given $number
.
// Sass.
@use 'sass:math';
// The `math.strip-unit()` function.
@function strip-unit($number) {
@return if(
type-of($number) == number,
math.div($number, ($number * 0 + 1)),
$number
);
}
https://github.com/angular-package/sass/blob/main/math/_math.strip-unit.function.scss
// Sass.
@use 'sass:math';
// Status: DONE
// The `math.strip-unit()` function strips the unit from a given `$number`.
// @param `$number` A `number` to strip the unit from.
// @return The return value is number without unit.
@function strip-unit($number) {
@return if(type-of($number) == number, math.div($number, ($number * 0 + 1)), $number);
}
// Examples.
// @debug strip-unit(10px); // 10
// @debug strip-unit(null); // null
// @debug strip-unit(false); // false
Parameters
$number
$number
A number
to strip the unit from.
Return
The return value is a number
without unit.
Examples
// Use.
@use '@angular-package/sass/math';
// Examples.
@debug math.strip-unit(10px); // 10
@debug math.strip-unit(null); // null
@debug math.strip-unit(false); // false
Last updated
Was this helpful?