math.percentage() turns a unitless decimal into a CSS % value in the sass:math module. This page covers the unitless rule, the fun fact that it equals $number * 100%, pairing with math.div(), the global percentage() alias, and five compiled examples.
01
Concept
Decimal → %
02
Module
@use "sass:math"
03
Input
Unitless only
04
Same as
* 100%
05
Global
percentage()
06
Practice
5 examples
Concept
What Is math.percentage()?
Design tokens often store fractions like 0.2 or ratios from math.div. CSS widths, columns, and progress bars usually want 20% instead. math.percentage($number) multiplies that unitless value by 100% for you.
Official docs place it under Other Functions and call out a fun fact: it is identical to writing $number * 100%.
math.percentage(0.2) → 20%
math.percentage(math.div(100px, 50px)) → 200%
math.percentage(1) → 100%
💡
Beginner tip
Think “fraction of a whole.” 0.25 means a quarter; math.percentage(0.25) writes that quarter as 25% in CSS.
Foundation
📝 Syntax
Load the math module, then call the function:
styles.scss
@use "sass:math";
math.percentage($number)
Parameters
Parameter
Type
Required
Description
$number
Number (unitless)
Yes
Usually a decimal between 0 and 1, but any unitless number works (for example 2 → 200%).
Return value
Type
Meaning
Number with %
The input multiplied by 100% (same as $number * 100%).
Modules
📦 Loading sass:math
Prefer the module API. Official docs also document a global name, percentage(), for older stylesheets.
styles.scss
// Recommended — namespaced
@use "sass:math";
$w: math.percentage(0.2);
// Optional — bring members into the current namespace
@use "sass:math" as *;
$w: percentage(0.2);
// Optional — custom namespace
@use "sass:math" as m;
$w: m.percentage(0.2);
// Legacy global name (still works in many setups)
$w: percentage(0.2);
⚠️
Put @use first
Keep @use "sass:math"; near the top of the file so math.percentage is available everywhere below.
Numbers
📏 Unitless Input Only
The argument must have no units. Lengths like 20px fail. Cancel units first with math.div(), then convert.
Call
Result
Notes
math.percentage(0.2)
20%
Official example
math.percentage(math.div(100px, 50px))
200%
Official example—units cancel first
math.percentage(0)
0%
Valid edge
math.percentage(1)
100%
Full width / full scale
0.2 * 100%
20%
Identical to math.percentage(0.2)
math.percentage(20px)
—
Error: input must be unitless
Support
🛠 Compatibility
This is about Sass compilers, not browsers. Compiled CSS receives a finished percentage—no math.percentage() call remains.
Implementation
math.percentage()
Notes
Dart Sass (modules)
Yes
Use @use "sass:math" (about 1.23+)
Global percentage()
Yes (legacy name)
Same idea; prefer the module form in new code
LibSass / Ruby Sass
No module API
May still expose global percentage(); prefer Dart Sass
Cheat Sheet
⚡ Quick Reference
Goal
Code
Import math
@use "sass:math";
Decimal to percent
math.percentage(0.2) → 20%
Ratio to percent
math.percentage(math.div($a, $b))
Same math, multiply form
0.2 * 100% → 20%
Full scale
math.percentage(1) → 100%
Legacy global
percentage(0.2)
Debug while learning
@debug math.percentage(0.2);
Compare
📋 percentage() vs * 100%
Official docs treat them as the same operation—pick the clearer style.
math.percentage($n)
$n * 100%
Result
Same percentage
Same percentage
Readability
Intent is obvious (“make a %”)
Shows the arithmetic directly
Module
Needs sass:math (or global)
No import required
When to prefer
Named helpers / shared tokens
One-off inline math
Compare
📋 Pairing with math.div()
Step
Code
Why
1. Cancel units
math.div(100px, 50px) → 2
Produces a unitless ratio
2. Convert to %
math.percentage(...) → 200%
Turns the ratio into a CSS percentage
One line
math.percentage(math.div($part, $whole))
Common column / progress pattern
Hands-On
Examples Gallery
Each example uses @use "sass:math". Open View Compiled CSS to see what Dart Sass emits.
Forgetting math.div — length ratios need division before percentage.
Pro Tips
💡 Best Practices
✅ Do
Use @use "sass:math" and math.percentage() in new SCSS
Keep design tokens as unitless fractions when possible
Pair with math.div() for part/whole length ratios
Use * 100% when the multiply form is clearer
Prefer Dart Sass for the modern module API
❌ Don’t
Pass px, em, or % inputs
Apply percentage twice to an already-percent-minded number
Rely on LibSass for sass:math
Expect the browser to re-evaluate math.percentage
Mix up opacity decimals (unitless) with CSS % without converting
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about math.percentage()
Unitless decimal in—CSS % out (same as * 100%).
5
Core concepts
📝01
Call
percentage(n)
API
📦02
Module
sass:math
@use
📏03
Input
unitless
Rule
⚡04
Same as
n * 100%
Docs
✓05
Pair
math.div
Ratio
❓ Frequently Asked Questions
math.percentage($number) converts a unitless number into a percentage. Example: math.percentage(0.2) is 20%. math.percentage(math.div(100px, 50px)) is 200%.
Add @use "sass:math"; then call math.percentage($number). Prefer this module form in new SCSS.
Yes. Official Sass docs say math.percentage($number) is identical to $number * 100%. Use whichever reads clearer in your stylesheet.
No. The input must be unitless. First cancel units with math.div—for example math.percentage(math.div($part, $whole)).
The global built-in is percentage($number). On sass:math the same helper is math.percentage(). Prefer math.percentage() in new code.
Built-in modules with @use need Dart Sass (about 1.23+). Older setups can still call the global percentage() name. LibSass and Ruby Sass do not load sass:math the same way.
Did you know?
Official Sass docs list math.percentage under Other Functions and highlight the fun fact that it is identical to $number * 100%—so you can choose the named helper or the multiply form without changing the compiled CSS.
math.percentage() converts unitless decimals into CSS percentages—the same math as $number * 100%. Keep inputs unitless, pair with math.div() for part/whole lengths, and prefer @use "sass:math" in new SCSS.