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

Parameters

$number

A number to strip the unit from.

Return

The return value is a number without unit.

Examples

Last updated

Was this helpful?