math.hypot($number...) returns the length of the n-dimensional vector whose components are the given numbers. For two sides that is the classic hypotenuse √(a² + b²); for three it is √(a² + b² + c²), and so on. Arguments must all have compatible units or all be unitless. The result takes the unit of the first number. Load it with @use "sass:math" on Dart Sass 1.25+.
Vector length — root-sum-square of the components.
Compatible units (or all unitless); first unit wins.
Supports list spread with $list....
Dart Sass 1.25+ via @use "sass:math".
One line: when several Sass lengths must become one distance, call math.hypot($number...).
Practice
Compile Notes
Practical checklist:
checklist.txt
1. @use "sass:math"
2. Pass compatible components (or all unitless)
3. Put the desired result unit first
4. Spread lists with $lengths... when helpful
5. Expect a fixed CSS length at compile time
Frequently Asked Questions
math.hypot($number...) returns the length of the n-dimensional vector whose components are the given numbers. For two values it is the hypotenuse: square root of a² + b². Example: math.hypot(3, 4) is 5.
Add @use "sass:math"; then call math.hypot(...) with one or more numbers. You can spread a list: math.hypot($lengths...). Requires Dart Sass 1.25+.
Arguments must all have compatible units or all be unitless. The result uses the unit of the first number. Example: math.hypot(1in, 10cm, 50px) returns a value in inches.
Official docs expose this as math.hypot() on sass:math. Prefer the module form with @use "sass:math".
math.abs() is one-dimensional distance from zero. math.hypot() combines several components into one length—like going from 1D absolute value to multi-dimensional distance.
Yes, when the side lengths are known at compile time. For viewport-based diagonals, compute in CSS or JavaScript instead—Sass hypot cannot use fluid vw values the same way.