Sass math.atan()

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

Definition and Usage

math.atan($number) returns the arctangent of $number in deg. $number must be unitless (any real slope ratio). Load it with @use "sass:math" on Dart Sass 1.25+.

Official sample.

math.atan(10) → 84.2894068625deg.

Inverse of tangent.

Think rise/run: math.atan(1) is 45deg. Pair with math.tan for round-trips. Need quadrant-aware points? Use math.atan2.

Unitless input only.

Do not pass px or deg into math.atan. Divide compatible lengths first (for example with math.div) to get a unitless slope.

Syntax

SCSS
@use "sass:math";

math.atan($number); //=> angle in deg

math.atan(10); // 84.2894068625deg
math.atan(1);  // 45deg
math.atan(0);  // 0deg
math.atan(-1); // -45deg

// Slope from lengths (must cancel units first)
math.atan(math.div(10px, 10px)); // 45deg

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

Pattern: build a unitless slope → math.atan for a CSS angle → use math.atan2 when x and y are separate and the quadrant matters.

Slope and Range

Unlike asin/acos, atan accepts any real unitless number:

InputResult
math.atan(0)0deg
math.atan(1)45deg
math.atan(-1)-45deg
math.atan(10)84.2894068625deg
Very large positiveApproaches 90deg
Very large negativeApproaches -90deg
Input with unitsError — must be unitless
atan vs atan2.

Official docs note that math.atan(math.div(1, -1)) is -45deg, while math.atan2(1, -1) is 135deg because atan2 keeps the point’s quadrant.

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

Arctangent of 10 is a steep angle just under 90°.

SCSS
@use "sass:math";

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

.basic {
  --ten: #{math.atan(10)};
}

How It Works

  1. Unitless 10 is a valid slope ratio.
  2. Result is in deg, not radians.
  3. Large slopes approach but do not exceed 90deg.
  4. Matches the official Sass docs sample.

Example 2 — Common Slope Angles

Zero, 1:1, and negative slopes map to familiar degrees.

SCSS
@use "sass:math";

.slopes {
  --zero: #{math.atan(0)};
  --one: #{math.atan(1)};
  --neg: #{math.atan(-1)};
}

How It Works

  1. atan(0) → 0deg.
  2. atan(1) → 45deg (equal rise/run).
  3. Negative slopes yield negative angles.
  4. Range stays within about -90deg…90deg.

Example 3 — atan vs atan2 (Quadrant)

Dividing first collapses quadrant information.

SCSS
@use "sass:math";

.compare {
  --atan-neg: #{math.atan(math.div(1, -1))};
  --atan2: #{math.atan2(1, -1)};
}

How It Works

  1. 1 / -1 becomes -1 before atan.
  2. atan(-1) is -45deg.
  3. atan2(1, -1) keeps the point in quadrant II → 135deg.
  4. Matches the official atan2 “heads up” contrast.

Example 4 — Round-Trip with math.tan

atan and tan undo each other for typical slopes.

SCSS
@use "sass:math";

.roundtrip {
  --back-num: #{math.tan(math.atan(1))};
  --back-ang: #{math.atan(math.tan(45deg))};
  --asin: #{math.asin(0.5)};
}

How It Works

  1. tan(atan(1)) recovers 1.
  2. atan(tan(45deg)) recovers 45deg.
  3. asin(0.5) is a different inverse (sine domain).
  4. Use tan/atan for slope geometry; sin/asin for opposite/hypotenuse ratios.

Example 5 — Emit a CSS Rotation from Slope

Turn a unitless slope token into rotate().

SCSS
@use "sass:math";

$slope: 1;

.angle {
  --deg: #{math.atan($slope)};
  transform: rotate(math.atan($slope));
}

How It Works

  1. Store the slope when reusing the same ratio.
  2. Sass compiles the angle before CSS sees it.
  3. transform receives plain 45deg.
  4. Useful for skew/rotation helpers driven by design tokens.

Edge Cases & Pitfalls

Most atan bugs are feeding units, or using atan when you needed atan2’s quadrant.

units

Input must be unitless

Cancel length units with math.div($rise, $run) before calling atan.

quad

Division loses quadrant

atan(y/x) cannot tell (1, -1) from (-1, 1). Prefer math.atan2($y, $x).

domain

Not limited to -1…1

Any real slope works. That is different from asin / acos.

module

Module-only helper

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

Sass Support

Prefer the module form with Dart Sass 1.25+.

APIStatus
math.atan()Dart Sass 1.25+ via @use "sass:math"
InputUnitless number (any real)
Return typeAngle in deg
LibSass / Ruby SassNo modern sass:math atan

Compile with the Dart Sass CLI.

Key Takeaways

  • Returns arctangent in deg from a unitless slope ratio.
  • Any real ratio works — not limited to -1…1.
  • Use atan2 for quadrants when x and y are separate.
  • Dart Sass 1.25+ via @use "sass:math".

One line: when a unitless slope must become a CSS angle, call math.atan($number).

Compile Notes

Practical checklist:

checklist.txt
1. @use "sass:math"
2. Pass a unitless slope (cancel length units first)
3. Expect a deg angle (~ -90deg…90deg)
4. Use math.atan2 when quadrant matters
5. Use math.tan for the forward transform

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(1)) recovers 1, 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.

Next: Sass math.atan2()

Return a quadrant-aware arctangent from separate $y and $x.

math.atan2() →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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