Sass math.pow()

Beginner
9 min read
Updated: Nov 2026
5 examples
Dart Sass 1.25+

Definition and Usage

math.pow($base, $exponent) raises $base to the power of $exponent. Both arguments must be unitless. Load it with @use "sass:math" on Dart Sass 1.25+.

Official samples.

math.pow(10, 2) → 100 · math.pow(100, math.div(1, 3)) → 4.6415888336 · math.pow(5, -2) → 0.04.

Inverse of log.

Pair with math.log: if y = math.pow(b, x), then math.log(y, b) recovers x (within floating-point precision).

Unitless only.

Do not pass px into math.pow. Compute the unitless factor first, then multiply by a length: 16px * math.pow(1.25, 3).

Syntax

SCSS
@use "sass:math";

math.pow($base, $exponent); //=> unitless number

math.pow(10, 2);                 // 100
math.pow(100, math.div(1, 3));   // 4.6415888336  (cube root)
math.pow(5, -2);                 // 0.04

math.pow(9, 0.5); // 3  (same idea as math.sqrt(9))

// Apply units after the power
16px * math.pow(1.25, 2); // 25px

// Module API — prefer math.pow after @use "sass:math"

Pattern: keep scale math unitless → call math.pow → multiply by a length when CSS needs units. Related: math.log, math.sqrt, math.div.

Exponents and Roots

How different exponents behave:

CallMeaningResult
math.pow(10, 2)Square100
math.pow(100, math.div(1, 3))Cube root4.6415888336
math.pow(5, -2)Reciprocal square0.04
math.pow(9, 0.5)Square root3
Input with unitsNot allowedError
Fractional = roots.

An exponent of 1/n is an n-th root. Prefer math.sqrt when you specifically need a square root.

SCSS Examples

Examples target Dart Sass 1.25+ with @use "sass:math". Open View Compiled CSS for verified output (matches official Sass docs samples).

Example 1 — Official Docs Sample (Integer Power)

Raise 10 to the power of 2.

SCSS
@use "sass:math";

@debug math.pow(10, 2); // 100

.basic {
  --a: #{math.pow(10, 2)};
}

How It Works

  1. Base and exponent are both unitless.
  2. 10² is 100.
  3. Result stays unitless.
  4. Matches the official Sass docs sample.

Example 2 — Official Docs Sample (Cube Root)

A fractional exponent acts as a root.

SCSS
@use "sass:math";

@debug math.pow(100, math.div(1, 3)); // 4.6415888336

.root {
  --b: #{math.pow(100, math.div(1, 3))};
}

How It Works

  1. math.div(1, 3) builds a unitless one-third.
  2. Exponent 1/3 means cube root.
  3. Result is about 4.6415888336.
  4. Matches the official Sass docs sample.

Example 3 — Official Docs Sample (Negative Exponent)

Negative powers invert the base.

SCSS
@use "sass:math";

@debug math.pow(5, -2); // 0.04

.neg {
  --c: #{math.pow(5, -2)};
}

How It Works

  1. 5⁻² means 1 / 5².
  2. 1 / 25 is 0.04.
  3. Still unitless on both sides.
  4. Matches the official Sass docs sample.

Example 4 — Round-Trip with math.log / math.sqrt

Power undoes a same-base log; half-power matches sqrt.

SCSS
@use "sass:math";

.roundtrip {
  --back: #{math.pow(10, math.log(10, 10))};
  --sqrt: #{math.pow(9, 0.5)};
  --sqrt2: #{math.sqrt(9)};
}

How It Works

  1. log₁₀(10) is 1, then 10¹ recovers 10.
  2. pow(9, 0.5) is the square root.
  3. math.sqrt(9) matches that result.
  4. Use sqrt when the intent is specifically a square root.

Example 5 — Modular Scale into CSS

Keep the power unitless, then use it as a factor or opacity.

SCSS
@use "sass:math";

$base: 2;
$exp: 3;

.scale {
  --steps: #{math.pow($base, $exp)};
  opacity: math.pow(0.5, 2);
  font-size: 16px * math.pow(1.25, 2);
}

How It Works

  1. 2³ becomes step count 8.
  2. 0.5² becomes opacity 0.25.
  3. Units attach after the power: 16px * 1.25² → 25px.
  4. Classic pattern for modular type scales.

Edge Cases & Pitfalls

Most pow bugs are feeding units into the helper, or forgetting negative exponents invert.

units

Unitless base and exponent

Multiply by a length after math.pow. Check with math.is-unitless.

neg

Negative exponents invert

math.pow(5, -2) is 0.04, not a negative length.

root

Prefer math.sqrt for square roots

math.pow($n, 0.5) works, but math.sqrt states the intent clearly.

module

Module-only helper

Use math.pow after @use "sass:math".

Sass Support

Prefer the module form with Dart Sass 1.25+.

APIStatus
math.pow()Dart Sass 1.25+ via @use "sass:math"
InputUnitless $base and unitless $exponent
Return typeUnitless number
LibSass / Ruby SassNo modern sass:math pow

Compile with the Dart Sass CLI.

Key Takeaways

  • Raises a unitless base to a unitless exponent.
  • Fractional = roots; negative = reciprocal power.
  • Inverse of math.log for the same base.
  • Apply CSS units after the power calculation.

One line: when a unitless Sass number needs an exponent, call math.pow($base, $exponent).

Compile Notes

Practical checklist:

checklist.txt
1. @use "sass:math"
2. Keep $base and $exponent unitless
3. Use fractional exponents for roots; negative for reciprocals
4. Multiply by a length after pow when CSS needs units
5. Pair with math.log for modular-scale round-trips

Frequently Asked Questions

math.pow($base, $exponent) raises $base to the power of $exponent. Example: math.pow(10, 2) is 100; math.pow(5, -2) is 0.04.
Add @use "sass:math"; then call math.pow($base, $exponent). Requires Dart Sass 1.25+.
No. Official docs require $base and $exponent to be unitless. Multiply the result by a length afterward, for example 16px * math.pow(1.25, 3).
Official docs expose this as math.pow() on sass:math. Prefer the module form with @use "sass:math".
They are inverse ideas: if y = math.pow(b, x), then math.log(y, b) recovers x (within floating-point precision). Pair them for modular scales.
Fractional exponents are roots—math.pow(100, math.div(1, 3)) is the cube root of 100. Negative exponents invert—math.pow(5, -2) is 1 / 5² = 0.04.

Next: Sass math.random()

Generate a random decimal or whole number at compile time.

math.random() →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful