math.percentage($number) converts a unitless number (usually a decimal between 0 and 1) into a CSS percentage. Official docs note it is identical to $number * 100%. Load it with @use "sass:math" (Dart Sass 1.23+ for modules; global percentage() also exists).
Use math.percentage($n) or $n * 100% — pick whichever reads clearer. Pair with math.div to build unitless ratios first.
Unitless input only.
Do not pass px or % directly. Cancel units first, and guard with math.is-unitless. Global percentage() is deprecated in modern Dart Sass.
Syntax
Syntax
SCSS
@use "sass:math";
math.percentage($number); //=> percentage
math.percentage(0.2); // 20%
math.percentage(math.div(100px, 50px)); // 200%
// Identical form from the official docs
0.2 * 100%; // 20%
// Global name (legacy / deprecated in modern Dart Sass)
percentage(0.2); // 20%
// Module API — prefer math.percentage after @use "sass:math"
Pattern: build a unitless ratio → math.percentage → emit a CSS % for widths, columns, or progress tokens.
Reference
Decimals and Ratios
Common conversions:
Call
Result
math.percentage(0.2)
20%
math.percentage(0.5)
50%
math.percentage(1)
100%
math.percentage(math.div(100px, 50px))
200%
0.2 * 100%
20% (identical)
Input with units
Error — must be unitless
Not limited to 0…1.
Values above 1 become percentages over 100% (for example a 2:1 ratio → 200%).
Pair with math.div to cancel length units into a ratio.
Prefer math.percentage over deprecated global percentage().
One line: when a unitless Sass ratio must become a CSS percentage, call math.percentage($number).
Practice
Compile Notes
Practical checklist:
checklist.txt
1. @use "sass:math"
2. Start from a unitless number (or math.div to cancel units)
3. Call math.percentage($number) — or use $number * 100%
4. Prefer math.percentage over global percentage()
5. Keep opacity/ratios unitless; do not wrap them
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)). Guard with math.is-unitless().
The global built-in is percentage($number). On sass:math the same helper is math.percentage(). Prefer math.percentage() in new code; global built-ins are deprecated in modern Dart Sass.
Built-in modules with @use need Dart Sass (about 1.23+). Older setups can still call the global percentage() name. Prefer math.percentage() for new code.