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
Concept
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).
Foundation
📝 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
Parameter
Type
Required
Description
$base
Number
Yes
Number to raise. Must be unitless.
$exponent
Number
Yes
Power to apply. Must be unitless. Can be fractional or negative.
Return value
Type
Situation
Result
Number
Valid unitless inputs
$base$exponent (unitless)
Number
Negative exponent
Reciprocal power (e.g. math.pow(5, -2) → 0.04)
Error
Arguments have units
Compile fails—keep math unitless, multiply by a length after
Modules
📦 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+.
Numbers
📏 How Units Work
Like math.log(), math.pow() accepts only unitless numbers. Compute the factor first, then multiply by a length.
Call
Result (approx.)
Notes
math.pow(10, 2)
100
Official example
math.pow(100, math.div(1, 3))
~4.6415888336
Cube root of 100
math.pow(5, -2)
0.04
Negative exponent
16px * math.pow(1.25, 3)
31.25px
Reattach units after pow
math.pow(2px, 3)
—
Error: base must be unitless
Support
🛠 Compatibility
This is about Sass compilers, not browsers. Compiled CSS receives a plain number.
Implementation
math.pow()
Notes
Dart Sass 1.25+
Yes
Preferred; needs @use "sass:math"
Dart Sass < 1.25
No
Upgrade Dart Sass
LibSass / Ruby Sass
No module API
Use Dart Sass for exponential math helpers
Cheat Sheet
⚡ Quick Reference
Goal
Code
Import math
@use "sass:math";
Square a number
math.pow(10, 2) → 100
Cube root
math.pow(100, math.div(1, 3))
Negative power
math.pow(5, -2) → 0.04
Modular scale step
$base * math.pow($ratio, $step)
Inverse with log
math.log(math.pow(10, 2), 10) → 2
Debug while learning
@debug math.pow(10, 2);
Compare
📋 pow vs log vs sqrt
Function
What it does
Best for
math.pow($base, $exp)
Raises base to a power
Modular scales, growth factors, roots via fractions
math.log($n, $base?)
Asks for the exponent
Finding which scale step a size sits on
math.sqrt($n)
Square root only
Simple √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.
Compare
📋 Sass math.pow() vs CSS / JS pow
Sass math.pow()
JS Math.pow / runtime
When it runs
Compile time (Dart Sass)
In the browser / runtime
Appears in CSS output?
No — only the numeric result
N/A (unless you set styles in JS)
Units
Unitless only
Plain numbers in JS
Best for
Fixed design tokens & scales in SCSS
Dynamic UI math from measured values
Hands-On
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.
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.
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.