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
Concept
What Is math.atan()?
Arctangent answers: which angle has this tangent (slope)? In Sass the answer is always an angle in degrees:
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.
Foundation
📝 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
Parameter
Type
Required
Description
$number
Number
Yes
Slope ratio (tangent). Must be unitless. Any real number is allowed—not limited to −1…1.
Return value
Type
Situation
Result
Angle
Any unitless real input
Arctangent in deg (approaches −90deg…90deg)
Error
Argument has units
Compile fails—pass a unitless ratio (e.g. math.div($rise, $run))
Modules
📦 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+.
Numbers
📏 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.
Call
Result (approx.)
Notes
math.atan(10)
84.2894068625deg
Official example
math.atan(0)
0deg
Flat slope
math.atan(1)
45deg
Rise equals run
math.atan(-1)
-45deg
Negative slope
math.atan(math.div(60px, 120px))
26.5650511771deg
Rise/run with units stripped
math.atan(10px)
—
Error: must be unitless
Support
🛠 Compatibility
This is about Sass compilers, not browsers. Compiled CSS receives a plain angle.
Implementation
math.atan()
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 trigonometric helpers
Cheat Sheet
⚡ Quick Reference
Goal
Code
Import math
@use "sass:math";
Angle from slope
math.atan(10) → ~84.2894068625deg
45° slope
math.atan(1) → 45deg
From lengths
math.atan(math.div($rise, $run))
Round-trip with tan
math.tan(math.atan(10)) ≈ 10
Debug while learning
@debug math.atan(10);
Compare
📋 atan vs tan vs atan2
Function
Direction
Best for
math.atan($n)
Slope → angle (deg)
Single rise/run ratio already combined
math.tan($angle)
Angle → unitless slope
Rise 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.
Compare
📋 Sass math.atan() vs CSS / JS atan
Sass math.atan()
CSS atan() / JS Math.atan
When it runs
Compile time (Dart Sass)
In the browser / runtime
Result unit
Always deg
JS returns radians; CSS follows CSS angle rules
Appears in CSS output?
No — only the angle result
CSS atan() can stay in the stylesheet
Best for
Fixed slopes known in SCSS
Dynamic slopes / animated 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 atan calls and landmark slopes.
Example 1 — Basic math.atan()
Official docs example: arctangent of 10 is about 84.29 degrees.
Use plain atan when you need full 360° quadrant info
Rely on LibSass for sass:math
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about math.atan()
Compile-time arctangent—unitless slope in, deg out.
5
Core concepts
📝01
Call
math.atan($n)
API
📦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.
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.