Sass math.atan() Function

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

What You’ll Learn

math.atan() is an inverse trigonometric helper in the sass:math module. Given a slope ratio (rise ÷ run), it returns the matching angle in deg. You will learn the unitless input rule, pairing with math.tan, when to prefer math.atan2, Dart Sass 1.25+ notes, and five compiled examples.

01

Concept

Arctangent

02

Module

@use "sass:math"

03

Input

Any unitless slope

04

Output

Angle in deg

05

Since

Dart Sass 1.25+

06

Practice

5 examples

What Is math.atan()?

Arctangent answers: which angle has this tangent (slope)? In Sass the answer is always an angle in degrees:

  • math.atan(10) → about 84.2894068625deg
  • math.atan(0)0deg · math.atan(1)45deg · math.atan(-1)-45deg
  • Very large ratios approach ±90deg (steep / near-vertical slopes)

Official docs place it under Trigonometric Functions next to math.tan(), math.asin(), and math.acos(). For two separate components with quadrant awareness, use math.atan2($y, $x).

💡
Beginner tip

Browsers never see math.atan. Dart Sass evaluates it and writes a plain angle (like 45deg) into your .css file. Think of the input as rise/run—not a length with units.

📝 Syntax

Load the math module, then pass a unitless number:

styles.scss
@use "sass:math";

math.atan($number)
// $number must be unitless → result is in deg

Parameters

ParameterTypeRequiredDescription
$numberNumberYesSlope ratio (tangent). Must be unitless. Any real number is allowed—not limited to −1…1.

Return value

TypeSituationResult
AngleAny unitless real inputArctangent in deg (approaches −90deg…90deg)
ErrorArgument has unitsCompile fails—pass a unitless ratio (e.g. math.div($rise, $run))

📦 Loading sass:math

styles.scss
// Recommended — namespaced
@use "sass:math";
$a: math.atan(1);

// Optional — bring members into the current namespace
@use "sass:math" as *;
$a: atan(1);

// Optional — custom namespace
@use "sass:math" as m;
$a: m.atan(1);
⚠️
Put @use first

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

📏 How Units Work

Unlike math.tan() (which takes an angle), math.atan() takes a unitless slope and returns deg. Strip length units with a same-unit ratio first.

CallResult (approx.)Notes
math.atan(10)84.2894068625degOfficial example
math.atan(0)0degFlat slope
math.atan(1)45degRise equals run
math.atan(-1)-45degNegative slope
math.atan(math.div(60px, 120px))26.5650511771degRise/run with units stripped
math.atan(10px)Error: must be unitless

🛠 Compatibility

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

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

⚡ Quick Reference

GoalCode
Import math@use "sass:math";
Angle from slopemath.atan(10)~84.2894068625deg
45° slopemath.atan(1)45deg
From lengthsmath.atan(math.div($rise, $run))
Round-trip with tanmath.tan(math.atan(10))10
Debug while learning@debug math.atan(10);

📋 atan vs tan vs atan2

FunctionDirectionBest for
math.atan($n)Slope → angle (deg)Single rise/run ratio already combined
math.tan($angle)Angle → unitless slopeRise from a known run
math.atan2($y, $x)Two components → angle (deg)Preserving quadrant (e.g. point in Q2)

Prefer math.atan for a single slope number. Prefer math.atan2 when x and y are separate and signs matter— official docs note that atan(y/x) can lose the quadrant.

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

Sass math.atan()CSS atan() / JS Math.atan
When it runsCompile time (Dart Sass)In the browser / runtime
Result unitAlways degJS returns radians; CSS follows CSS angle rules
Appears in CSS output?No — only the angle resultCSS atan() can stay in the stylesheet
Best forFixed slopes known in SCSSDynamic slopes / animated values

Examples Gallery

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

📚 Getting Started

Official-style atan calls and landmark slopes.

Example 1 — Basic math.atan()

Official docs example: arctangent of 10 is about 84.29 degrees.

styles.scss
@use "sass:math";

@debug math.atan(10); // 84.2894068625deg

.demo {
  --angle: #{math.atan(10)};
  rotate: math.atan(10);
}

How It Works

A slope of 10 (rise ten times the run) is a steep angle—just under 90°. Sass returns that angle in deg, ready for CSS.

Example 2 — Landmark Slopes

Memorize flat, 45°, and mirrored negative slopes.

styles.scss
@use "sass:math";

.landmarks {
  --a0: #{math.atan(0)};   // 0deg
  --a1: #{math.atan(1)};   // 45deg
  --am1: #{math.atan(-1)}; // -45deg
}

How It Works

When rise equals run, tangent is 1 and arctangent is exactly 45deg. Negative slopes produce negative angles.

📈 Practical Patterns

Rise/run geometry, round-trips, and steep approaches.

Example 3 — Angle from Rise and Run

Strip units with math.div, then convert the slope to an angle.

styles.scss
@use "sass:math";

$run: 120px;
$rise: 60px;
$angle: math.atan(math.div($rise, $run));

.ramp {
  width: $run;
  height: $rise;
  rotate: $angle;
  --angle: #{$angle};
}

How It Works

math.div(60px, 120px) is the unitless ratio 0.5. Arctangent of 0.5 is about 26.565deg.

Example 4 — Round-Trip with math.tan()

Recover a slope from an angle, or an angle from a slope.

styles.scss
@use "sass:math";

$slope: 10;
$angle: math.atan($slope);       // ~84.289deg
$back: math.tan($angle);         // ~10

.check {
  rotate: $angle;
  --slope: #{$back};
}

How It Works

math.atan and math.tan undo each other for ordinary slopes (within Sass floating-point precision).

Example 5 — Steep Slopes Approach 90°

Larger ratios get closer to vertical—but never quite reach 90° with a finite number.

styles.scss
@use "sass:math";

.steep {
  --a10: #{math.atan(10)};
  --a100: #{math.atan(100)};
  --a1000: #{math.atan(1000)};
}

How It Works

As the slope grows, arctangent crowds toward 90deg. That is why near-vertical UI angles still use large finite ratios, not infinity.

🚀 Real-World Use Cases

  • Ramp angles — turn rise/run lengths into a rotate angle.
  • Skew tokens — author slopes as ratios; Sass emits degrees.
  • Round-trip checks — validate that tan ↔ atan stay consistent.
  • Icon geometry — derive pointer or chevron angles from offsets.
  • Teaching inverse trig — show how atan undoes tan with @debug.
  • Quadrant-safe work — switch to math.atan2 when x/y signs matter.

🧠 How Compilation Works

1

Write SCSS

Call math.atan($number) after @use.

Source
2

Require unitless

Sass rejects lengths; convert rise/run with math.div first.

Validate
3

Compute arctangent

Return an angle in deg for the slope ratio.

Atan
4

Plain CSS ships

The browser only receives the final angle (e.g. 45deg).

⚠️ Common Pitfalls

  • Passing lengths into atan — input is a unitless ratio, not px.
  • Expecting radians — Sass atan always returns deg (unlike JS Math.atan).
  • Losing quadrantatan(y/x) can flip signs; use math.atan2($y, $x) when needed.
  • Confusing with asin/acos — atan accepts any real slope, not only −1…1.
  • Old Dart Sass — need 1.25+; LibSass lacks the module API.

💡 Best Practices

✅ Do

  • Use @use "sass:math" and math.atan() in new SCSS
  • Pass unitless slopes (use math.div for lengths)
  • Pair with math.tan() for round-trips
  • Reach for math.atan2 when x/y signs matter
  • Prefer Dart Sass 1.25+

❌ Don’t

  • Pass px / deg into math.atan
  • Assume JS-style radian output
  • Expect the browser to re-evaluate math.atan
  • Use plain atan when you need full 360° quadrant info
  • Rely on LibSass for sass:math

Key Takeaways

Knowledge Unlocked

Five things to remember about math.atan()

Compile-time arctangent—unitless slope in, deg out.

5
Core concepts
📦 02

Module

sass:math

@use
🔢 03

Input

any unitless slope

Rule
🌡️ 04

Output

always deg

Angle
05

Since

Dart Sass 1.25+

Tooling

❓ Frequently Asked Questions

math.atan($number) returns the arctangent of a unitless number in degrees. Example: math.atan(10) is about 84.2894068625deg.
Add @use "sass:math"; then call math.atan($number). Requires Dart Sass 1.25+.
Any unitless number (a slope ratio like rise/run). Unlike asin/acos, it is not limited to -1…1. Lengths like px are not allowed.
An angle in deg, typically between about -90deg and 90deg. Large positive inputs approach 90deg; large negative inputs approach -90deg.
They are inverse ideas: math.tan(math.atan(10)) recovers about 10, and math.atan(math.tan(45deg)) recovers 45deg (within floating-point precision).
Use math.atan2($y, $x) when you have separate vertical and horizontal components and need the correct quadrant. Plain math.atan(math.div($y, $x)) loses quadrant information.
Did you know?

Official Sass docs highlight math.atan2($y, $x) as distinct from atan(y/x) because it keeps the correct quadrant. For example, math.atan2(1, -1) is 135deg, while dividing first collapses both sign patterns toward the same half-plane answer.

Conclusion

math.atan() turns a unitless slope into a compile-time angle in deg. Strip length units with ratios, pair with math.tan for round-trips, and use math.atan2 when you need quadrant-safe two-argument math.

Continue with math.tan(), math.atan2(), or math.asin().

More Sass Math

Continue with quadrant-safe atan2 in the math module.

math.atan2() →

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