math.is-unitless($number) returns whether $number has no units. It is a boolean check only — it does not strip units. Load it with @use "sass:math" (Dart Sass 1.23+ for modules).
Official docs: the global helper is unitless; the module name is is-unitless so it reads like a yes/no question. Prefer math.is-unitless; global built-ins are deprecated in modern Dart Sass.
Does not remove units.
To cancel a known unit, divide by 1 of that unit — for example math.div(18px, 1px) → 18.
Syntax
Syntax
SCSS
@use "sass:math";
math.is-unitless($number); //=> boolean
math.is-unitless(100); // true
math.is-unitless(100px); // false
// Global name (legacy / deprecated in modern Dart Sass)
unitless(100); // true
// Module API — prefer math.is-unitless after @use "sass:math"
Pattern: inspect a token → branch with @if → only then call helpers that require unitless input (math.log, math.pow, math.sqrt). Inspect the unit string with math.unit.
Reference
What Counts as Unitless
Verified results for common numbers:
Call
Result
math.is-unitless(100)
true
math.is-unitless(0)
true
math.is-unitless(100px)
false
math.is-unitless(50%)
false
math.is-unitless(1.5rem)
false
math.is-unitless(45deg)
false
Any unit fails the check.
Lengths, percentages, angles, and times all return false. Only a bare number returns true.
Does not strip units — cancel with math.div when needed.
Module name is is-unitless; global alias is unitless.
Prefer math.is-unitless over deprecated global unitless().
One line: before calling a unitless-only math helper, check with math.is-unitless($number).
Practice
Compile Notes
Practical checklist:
checklist.txt
1. @use "sass:math"
2. Call math.is-unitless($number)
3. true → safe for log/pow/sqrt/acos-style helpers
4. false → cancel units with math.div or branch with @if
5. Prefer math.is-unitless over global unitless()
Frequently Asked Questions
math.is-unitless($number) returns true when $number has no CSS units, and false when it has any unit such as px, %, or deg. Example: math.is-unitless(100) is true; math.is-unitless(100px) is false.
Add @use "sass:math"; then call math.is-unitless($number). Prefer this module form in new SCSS.
Official docs expose the global built-in as unitless($number). On sass:math the name is is-unitless to read more like a yes/no question. Prefer math.is-unitless() in new code; global built-ins are deprecated in modern Dart Sass.
No. It only reports whether units are present. To remove a known unit, divide by 1 of that unit—for example math.div(18px, 1px) yields the unitless 18.
Use it before helpers that require unitless input (math.log, math.pow, math.sqrt, math.acos, and friends), or in mixins that accept either ratios or lengths.
Built-in modules with @use need Dart Sass (about 1.23+). Older setups can still call the global unitless() name. Prefer math.is-unitless() for new code.