Official docs say this is intended for debugging. The string format is not guaranteed across Sass versions or implementations—do not build production design-system logic on the exact text.
Need a yes/no check?
Use math.is-unitless() when you only care whether units exist, not what they are.
Returns a quoted unit string (empty when unitless).
Debugging only — format is not a stable contract.
Shows compounds like px*px and px/s.
Pair with is-unitless / compatible for real guards.
One line: when you need to see which units a Sass number carries while debugging, call math.unit($number).
Practice
Compile Notes
Practical checklist:
checklist.txt
1. @use "sass:math"
2. Call math.unit($number) while debugging
3. Expect a quoted string ("" if unitless)
4. Do not depend on the exact format in production
5. Prefer is-unitless / compatible for logic
Frequently Asked Questions
math.unit($number) returns a quoted string showing the number's units. Examples: math.unit(100) is ""; math.unit(100px) is "px"; math.unit(5px * 10px) is "px*px"; math.unit(math.div(5px, 1s)) is "px/s".
Add @use "sass:math"; then call math.unit($number). Prefer this module form in new SCSS.
Official Sass docs say it is intended for debugging. The output format is not guaranteed to stay the same across Sass versions or implementations, so avoid building critical design-system logic on the exact string.
The global built-in is unit($number). On sass:math the same helper is math.unit(). Prefer math.unit() in new code; global built-ins are deprecated in modern Dart Sass.
math.is-unitless($n) returns a boolean (has units or not). math.unit($n) returns the unit string itself, which is useful when you want to see px, %, px*px, or px/s while debugging.
Built-in modules with @use need Dart Sass (about 1.23+). Older setups can still call the global unit() name. LibSass and Ruby Sass do not load sass:math the same way.