math.cos($number) returns the cosine of $number. Pass an angle whose units are compatible with deg, or a unitless number treated as radians. The result is a unitless ratio (typically between -1 and 1). Load it with @use "sass:math" on Dart Sass 1.25+.
Unitless input = radians; prefer explicit deg when needed.
Compile-time — CSS gets a fixed number.
Dart Sass 1.25+ via @use "sass:math".
One line: when an angle must become a fixed cosine ratio in CSS, call math.cos($number).
Practice
Compile Notes
Practical checklist:
checklist.txt
1. @use "sass:math"
2. Pass deg-compatible angle or unitless radians
3. Expect a unitless ratio (about -1…1)
4. Multiply by a length when you need CSS offsets
5. Use CSS cos() for runtime angles
Frequently Asked Questions
math.cos($number) returns the cosine of an angle. Example: math.cos(100deg) is about -0.1736481777; math.cos(1rad) and math.cos(1) are about 0.5403023059.
Add @use "sass:math"; then call math.cos($number). Requires Dart Sass 1.25+.
An angle compatible with deg (such as deg, rad, turn, grad), or a unitless number. Unitless values are treated as radians.
No. Cosine is a unitless ratio (typically between -1 and 1). Multiply by a length if you need a CSS length, for example $r * math.cos(30deg).
Sass math.cos() runs at compile time and writes a fixed number. CSS cos() stays in the stylesheet and can use runtime values like custom properties in supporting browsers.
Official docs expose this as math.cos() on sass:math. Prefer the module form with @use "sass:math".