Skip to content

Units

Unit conversion and manipulation functions for CSS values. These functions help you work with different CSS units, convert between them, and perform unit-related operations in your Sass code.

strip-units()

Removes units from a number.

ParameterTypeDefault ValueDescription
$numbernumber-The number with units to strip
scss
$unitless: strip-units(16px);
// Returns: 16
scss
16

units-are-same()

Determines whether two values have the same units.

ParameterTypeDefault ValueDescription
$value1number-The first value to compare
$value2number-The second value to compare
scss
$same: units-are-same(10px, 20px);
// Returns: true
scss
true

rem()

Converts pixels to rem units.

ParameterTypeDefault ValueDescription
$valuenumber-The pixel value to convert
$rationumber10The base ratio for conversion
scss
$rem: rem(16px);
// Returns: 1.6rem
scss
1.6rem

em()

Converts pixels to em units.

ParameterTypeDefault ValueDescription
$valuenumber-The pixel value to convert
$rationumber10The base ratio for conversion
scss
$em: em(16px);
// Returns: 1.6em
scss
1.6em

vh()

Calculates viewport height percentage using CSS custom properties.

ParameterTypeDefault ValueDescription
$numbernumber-The percentage number
scss
$height: vh(50);
// Returns: calc(50 * var(--vh, 1vh))
scss
calc(50 * var(--vh, 1vh))