math.is-unitless() is a unit helper in the sass:math module. It answers one question: does this number have any CSS units? This page covers the boolean return, the global unitless() alias, how it guards exponential and inverse-trig helpers, and five compiled examples.
01
Concept
Has units?
02
Module
@use "sass:math"
03
Returns
true / false
04
Global
unitless()
05
Guards
log · pow · sqrt
06
Practice
5 examples
Concept
What Is math.is-unitless()?
A Sass number is either unitless (just a magnitude like 100) or it carries a CSS unit (100px, 50%, 45deg). Some math helpers only accept unitless input. Others behave differently when units are present.
math.is-unitless($number) returns whether the value has no units. Official docs place it under Unit Functions next to math.compatible().
“Unitless” means no unit string at all—not “zero.” 0 is unitless and returns true; 0px still has a unit and returns false.
Foundation
📝 Syntax
Load the math module, then call the function:
styles.scss
@use "sass:math";
math.is-unitless($number)
Parameters
Parameter
Type
Required
Description
$number
Number
Yes
The Sass number to inspect (with or without units).
Return value
Type
Meaning
true
The number has no units (for example 100 or 0.75).
false
The number has one or more units (for example 100px, 10%, px*px).
Modules
📦 Loading sass:math
Prefer the module API. Official docs also document a global name, unitless(), for older stylesheets.
styles.scss
// Recommended — namespaced
@use "sass:math";
$ok: math.is-unitless(100);
// Optional — bring members into the current namespace
@use "sass:math" as *;
$ok: is-unitless(100);
// Optional — custom namespace
@use "sass:math" as m;
$ok: m.is-unitless(100);
// Legacy global name (still works in many setups)
$ok: unitless(100);
⚠️
Name tip
Module form: is-unitless. Global form: unitless. Same check—new SCSS should use math.is-unitless().
Numbers
📏 What Counts as Unitless?
Any attached unit makes the answer false—including percentages, angles, times, and compound units like px*px. Dividing matching units away (for example px / px) produces a unitless ratio.
Call
Result
Notes
math.is-unitless(100)
true
Official example
math.is-unitless(100px)
false
Official example
math.is-unitless(0)
true
Zero can still be unitless
math.is-unitless(0px)
false
Zero with a unit
math.is-unitless(10%)
false
Percent is a unit
math.is-unitless(1deg)
false
Angles have units
math.is-unitless(math.div(5px, 1px))
true
Matching units cancel
math.is-unitless(5px * 10px)
false
Compound px*px
Support
🛠 Compatibility
This is about Sass compilers, not browsers. The boolean is resolved while compiling—browsers never see a math.is-unitless() call.
Implementation
math.is-unitless()
Notes
Dart Sass (modules)
Yes
Use @use "sass:math" (about 1.23+)
Global unitless()
Yes (legacy name)
Same idea; prefer the module form in new code
LibSass / Ruby Sass
No module API
May still expose global unitless(); prefer Dart Sass
Cheat Sheet
⚡ Quick Reference
Goal
Code
Import math
@use "sass:math";
Check for no units
math.is-unitless($n)
Plain number
math.is-unitless(100) → true
With units
math.is-unitless(100px) → false
Strip a known unit
math.div($n, 1px) when $n is in px
Guard before log/pow
@if math.is-unitless($n) { ... }
Legacy global
unitless($n)
Debug while learning
@debug math.is-unitless(100);
Compare
📋 is-unitless vs unitless
Same check, different names depending on how you load Sass math.
math.is-unitless()
unitless()
Where
sass:math module
Global built-in
Load with
@use "sass:math"
No import required
Modern style?
Yes—preferred
Legacy-friendly
Behavior
Boolean unit presence check
Same idea
Compare
📋 Why Other Math Functions Care
Function
Needs unitless?
How is-unitless helps
math.log() / math.pow() / math.sqrt()
Yes
Guard or strip units first
math.acos() / math.asin() / math.atan()
Yes
Confirm the ratio has no units
math.percentage()
Yes (unitless input)
Check before converting to %
math.compatible()
Different job
Compares two numbers’ units; does not ask “unitless?”
Use math.is-unitless() when you care about one number. Use math.compatible() when you care whether two numbers can work together.
Hands-On
Examples Gallery
Each example uses @use "sass:math". Open View Compiled CSS to see what Dart Sass emits.
Learning units — print true/false while exploring how division cancels units.
🧠 How Compilation Works
1
Write SCSS
Call math.is-unitless($n) after @use.
Source
2
Inspect units
Sass looks at whether the number carries any unit string.
Validate
3
Return a boolean
true means bare magnitude; false means units are present.
Result
4
✓
Branches compile away
Your @if path ships only the CSS that matched.
Watch Out
⚠️ Common Pitfalls
Thinking zero is special — 0px is still not unitless.
Expecting stripping — the function only reports; use math.div to remove a known unit.
Percentages — % counts as a unit, so is-unitless(50%) is false.
Confusing the two names — module = is-unitless, global = unitless.
Skipping the check before log/pow — those calls error on lengths at compile time.
Pro Tips
💡 Best Practices
✅ Do
Use @use "sass:math" and math.is-unitless() in new SCSS
Guard log, pow, sqrt, and inverse-trig helpers
Cancel units with math.div when you need a ratio
Pair with math.compatible() when comparing two lengths
Prefer Dart Sass for the modern module API
❌ Don’t
Assume true means the value is between 0 and 1
Treat % as unitless
Rely on LibSass for sass:math
Ship debug custom properties in production unless you need them
Forget the global name is unitless, not is-unitless
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about math.is-unitless()
Boolean unit presence—true means no CSS units.
5
Core concepts
📝01
Call
is-unitless(n)
API
📦02
Module
sass:math
@use
📏03
Returns
boolean
true/false
⚡04
Global
unitless()
Alias
✓05
Use
guard math
@if
❓ 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.
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. LibSass and Ruby Sass do not load sass:math the same way.
Did you know?
Official Sass docs list math.is-unitless under Unit Functions with math.compatible and math.unit. The global twin is simply named unitless()—shorter, but less explicit than is-unitless.
math.is-unitless() is a simple boolean check for missing CSS units. Use it before helpers that reject lengths, remember the global alias is unitless(), and keep new code on @use "sass:math".