Sass math.pow() Function

Beginner
⏱️ 12 min read
📚 Updated: Jul 2026
🎯 5 Examples
sass:math · Dart Sass 1.25+

What You’ll Learn

math.pow() is an exponential helper in the sass:math module. It raises a unitless base to a power—squares, roots, negative exponents, and modular scales. You will learn unit rules, pairing with math.log, Dart Sass 1.25+ notes, and five compiled examples.

01

Concept

Exponentiation

02

Module

@use "sass:math"

03

Call

math.pow($base, $exp)

04

Units

Unitless only

05

Since

Dart Sass 1.25+

06

Practice

5 examples

What Is math.pow()?

math.pow($base, $exponent) multiplies the base by itself according to the exponent. In plain words: base raised to the power of exponent.

  • math.pow(10, 2)100 (10 × 10)
  • math.pow(100, math.div(1, 3)) → about 4.6415888336 (cube root of 100)
  • math.pow(5, -2)0.04 (1 ÷ 25)

Official docs group it with math.log() and math.sqrt under Exponential Functions. Powers grow a scale; logs recover the step index.

💡
Beginner tip

Browsers never see math.pow. Dart Sass evaluates it and writes a plain number into your .css file. Reattach units yourself: $size * math.pow($ratio, $step).

📝 Syntax

Load the math module, then pass a unitless base and exponent:

styles.scss
@use "sass:math";

math.pow($base, $exponent)
// both arguments must be unitless

Parameters

ParameterTypeRequiredDescription
$baseNumberYesNumber to raise. Must be unitless.
$exponentNumberYesPower to apply. Must be unitless. Can be fractional or negative.

Return value

TypeSituationResult
NumberValid unitless inputs$base$exponent (unitless)
NumberNegative exponentReciprocal power (e.g. math.pow(5, -2)0.04)
ErrorArguments have unitsCompile fails—keep math unitless, multiply by a length after

📦 Loading sass:math

styles.scss
// Recommended — namespaced
@use "sass:math";
$n: math.pow(10, 2);

// Optional — bring members into the current namespace
@use "sass:math" as *;
$n: pow(10, 2);

// Optional — custom namespace
@use "sass:math" as m;
$n: m.pow(10, 2);
⚠️
Put @use first

Keep @use "sass:math"; near the top of the file. math.pow() needs Dart Sass 1.25+.

📏 How Units Work

Like math.log(), math.pow() accepts only unitless numbers. Compute the factor first, then multiply by a length.

CallResult (approx.)Notes
math.pow(10, 2)100Official example
math.pow(100, math.div(1, 3))~4.6415888336Cube root of 100
math.pow(5, -2)0.04Negative exponent
16px * math.pow(1.25, 3)31.25pxReattach units after pow
math.pow(2px, 3)Error: base must be unitless

🛠 Compatibility

This is about Sass compilers, not browsers. Compiled CSS receives a plain number.

Implementationmath.pow()Notes
Dart Sass 1.25+YesPreferred; needs @use "sass:math"
Dart Sass < 1.25NoUpgrade Dart Sass
LibSass / Ruby SassNo module APIUse Dart Sass for exponential math helpers

⚡ Quick Reference

GoalCode
Import math@use "sass:math";
Square a numbermath.pow(10, 2)100
Cube rootmath.pow(100, math.div(1, 3))
Negative powermath.pow(5, -2)0.04
Modular scale step$base * math.pow($ratio, $step)
Inverse with logmath.log(math.pow(10, 2), 10)2
Debug while learning@debug math.pow(10, 2);

📋 pow vs log vs sqrt

FunctionWhat it doesBest for
math.pow($base, $exp)Raises base to a powerModular scales, growth factors, roots via fractions
math.log($n, $base?)Asks for the exponentFinding which scale step a size sits on
math.sqrt($n)Square root onlySimple √n when you do not need a general root

Prefer math.pow when you know the step and want the value. Prefer math.log when you know the value and want the step. math.sqrt($n) is the same idea as math.pow($n, 0.5), written more clearly.

📋 Sass math.pow() vs CSS / JS pow

Sass math.pow()JS Math.pow / runtime
When it runsCompile time (Dart Sass)In the browser / runtime
Appears in CSS output?No — only the numeric resultN/A (unless you set styles in JS)
UnitsUnitless onlyPlain numbers in JS
Best forFixed design tokens & scales in SCSSDynamic UI math from measured values

Examples Gallery

Each example uses @use "sass:math". Open View Compiled CSS to see what Dart Sass emits.

📚 Getting Started

Official-style powers, roots, and negative exponents.

Example 1 — Basic math.pow()

Raise 10 to the power of 2—same as the official docs.

styles.scss
@use "sass:math";

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

.demo {
  --ten-squared: #{math.pow(10, 2)};
  z-index: math.pow(2, 3); // 8
}

How It Works

math.pow(10, 2) is 10² = 100. math.pow(2, 3) is 2³ = 8.

Example 2 — Fractional Exponent (Cube Root)

A fraction like 1/3 turns pow into a root—official cube-root style example.

styles.scss
@use "sass:math";

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

.root {
  --cube-root-100: #{math.pow(100, math.div(1, 3))};
  // square root via pow (same idea as math.sqrt)
  --sqrt-81: #{math.pow(81, 0.5)};
}

How It Works

math.div(1, 3) avoids the old / ambiguity. Raising to 1/3 is the cube root; raising to 0.5 is the square root.

Example 3 — Negative Exponent

Negative powers invert: base−n = 1 / basen.

styles.scss
@use "sass:math";

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

.fade {
  // 1 / 5² = 0.04 → useful as a soft opacity token
  opacity: math.pow(5, -2);
  --inv-square: #{math.pow(5, -2)};
}

How It Works

5² is 25, so 5−2 is 1/25 = 0.04—exactly the official docs result.

📈 Practical Patterns

Modular type scales and round-trips with log.

Example 4 — Modular Type Scale

Grow a base size by a fixed ratio for heading steps.

styles.scss
@use "sass:math";

$base: 16px;
$ratio: 1.25; // major third-ish

.h1 { font-size: $base * math.pow($ratio, 3); } // 31.25px
.h2 { font-size: $base * math.pow($ratio, 2); } // 25px
.h3 { font-size: $base * math.pow($ratio, 1); } // 20px
.body { font-size: $base; }

How It Works

The ratio stays unitless inside math.pow. Multiplying by $base puts px back on the result.

Example 5 — Round-Trip with math.log()

Build a size with pow, then recover the step index with log.

styles.scss
@use "sass:math";

$base: 1rem;
$ratio: 1.25;
$step: 3;

$size: $base * math.pow($ratio, $step);
$index: math.log(math.div($size, $base), $ratio);

.heading {
  font-size: $size;
  --scale-index: #{$index};
}

How It Works

1rem × 1.25³ is 1.953125rem. Logging that ratio with base 1.25 recovers step 3.

🚀 Real-World Use Cases

  • Modular type scales — generate heading sizes from a base and ratio.
  • Spacing ramps — grow padding or gaps exponentially across breakpoints.
  • Roots without sqrt only — cube roots and other nth roots via fractional exponents.
  • Soft opacity / weight curves — negative powers for gentle falloff tokens.
  • Design tokens — keep ratios unitless, multiply by rem/px once at the end.
  • Teaching exponentials — pair with math.log to show inverse operations.

🧠 How Compilation Works

1

Write SCSS

Call math.pow($base, $exponent) after @use.

Source
2

Require unitless

Sass rejects bases or exponents with units.

Validate
3

Raise to power

Compute baseexponent, including fractional and negative cases.

Pow
4

Plain CSS ships

The browser only receives the final number (or a length you rebuild).

⚠️ Common Pitfalls

  • Passing px / rem into pow — keep both args unitless; multiply by a length after.
  • Forgetting @usemath.pow needs sass:math loaded.
  • Using / for fractions — prefer math.div(1, 3) for clear division.
  • Expecting CSS to re-run pow — only the computed result appears in the stylesheet.
  • Old Dart Sass — need 1.25+; LibSass lacks the module API.

💡 Best Practices

✅ Do

  • Use @use "sass:math" and math.pow() in new SCSS
  • Keep base and exponent unitless
  • Multiply by rem/px after computing the factor
  • Pair with math.log for scale round-trips
  • Prefer Dart Sass 1.25+

❌ Don’t

  • Expect the browser to re-evaluate math.pow
  • Pass lengths with units directly into math.pow
  • Hand-multiply $n * $n * $n when a clear exponent helps
  • Use Sass pow for live measured layout (use JS instead)
  • Rely on LibSass for sass:math

Key Takeaways

Knowledge Unlocked

Five things to remember about math.pow()

Compile-time exponentiation—unitless only; reattach units after.

5
Core concepts
📦 02

Module

sass:math

@use
🔢 03

Also

roots & negatives

Exponents
📏 04

Units

unitless only

Rule
05

Since

Dart Sass 1.25+

Tooling

❓ 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.
Did you know?

Official Sass docs place math.pow under Exponential Functions with math.log and math.sqrt. A modular scale is often just $base * math.pow($ratio, $step)—pow builds the size; log finds the step.

Conclusion

math.pow() gives you compile-time exponentiation: squares, roots, negative powers, and modular scales. Keep arguments unitless, reattach lengths afterward, and pair with math.log when you need the step index back.

Continue with math.random(), math.log(), or math.round().

More Sass Math

Continue with compile-time random numbers in the math module.

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.

5 people found this page helpful