math.acos() is an inverse trigonometric helper in the sass:math module. Given a cosine factor, it returns the matching angle in deg. You will learn the unitless input rule, NaNdeg behavior, pairing with math.cos, Dart Sass 1.25+ notes, and five compiled examples.
01
Concept
Arccosine
02
Module
@use "sass:math"
03
Input
Unitless (−1…1)
04
Output
Angle in deg
05
Since
Dart Sass 1.25+
06
Practice
5 examples
Concept
What Is math.acos()?
Arccosine answers: which angle has this cosine? In Sass the answer is always an angle in degrees:
Official docs place it under Trigonometric Functions next to math.cos(), math.asin, and math.atan. Use acos when you already have a unitless factor and need the angle back.
💡
Beginner tip
Browsers never see math.acos. Dart Sass evaluates it and writes a plain angle (like 60deg) into your .css file—or NaNdeg if the input was invalid.
Foundation
📝 Syntax
Load the math module, then pass a unitless number:
styles.scss
@use "sass:math";
math.acos($number)
// $number must be unitless → result is in deg
Parameters
Parameter
Type
Required
Description
$number
Number
Yes
Cosine factor. Must be unitless. Valid domain is typically -1 to 1.
Return value
Type
Situation
Result
Angle
Input in −1…1
Arccosine in deg (0deg…180deg)
Angle
Input outside −1…1
NaNdeg (as in the official docs)
Error
Argument has units
Compile fails—pass a unitless factor
Modules
📦 Loading sass:math
styles.scss
// Recommended — namespaced
@use "sass:math";
$a: math.acos(0.5);
// Optional — bring members into the current namespace
@use "sass:math" as *;
$a: acos(0.5);
// Optional — custom namespace
@use "sass:math" as m;
$a: m.acos(0.5);
⚠️
Put @use first
Keep @use "sass:math"; near the top of the file. math.acos() needs Dart Sass 1.25+.
Numbers
📏 How Units Work
Unlike math.cos() (which takes an angle), math.acos() takes a unitless factor and returns deg.
Call
Result
Notes
math.acos(0.5)
60deg
Official example
math.acos(2)
NaNdeg
Official out-of-range example
math.acos(1)
0deg
Cosine of 0°
math.acos(0)
90deg
Cosine of 90°
math.acos(-1)
180deg
Cosine of 180°
math.acos(0.5px)
—
Error: must be unitless
Support
🛠 Compatibility
This is about Sass compilers, not browsers. Compiled CSS receives a plain angle (or NaNdeg).
Implementation
math.acos()
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 cosine
math.acos(0.5) → 60deg
Out of range
math.acos(2) → NaNdeg
Clamp before acos
math.acos(math.clamp(-1, $n, 1))
Round-trip with cos
math.cos(math.acos(0.5)) ≈ 0.5
Debug while learning
@debug math.acos(0.5);
Compare
📋 acos vs cos vs asin
Function
Direction
Best for
math.acos($n)
Factor → angle (deg)
Recovering an angle from a cosine factor
math.cos($angle)
Angle → unitless factor
Horizontal projection / circular X
math.asin($n)
Factor → angle (deg)
Recovering an angle from a sine factor
Prefer math.acos when the known value is a cosine-like ratio. Prefer math.cos when you already know the angle.
Compare
📋 Sass math.acos() vs CSS / JS acos
Sass math.acos()
CSS acos() / JS Math.acos
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 acos() can stay in the stylesheet
Best for
Fixed factors known in SCSS
Dynamic factors / 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 acos calls and landmark values.
Example 1 — Basic math.acos()
Official docs example: arccosine of 0.5 is 60 degrees.
math.acos() turns a unitless cosine factor into a compile-time angle in deg. Keep inputs in −1…1 (clamp when needed), pair with math.cos for round-trips, and watch for NaNdeg on invalid values.