math.sin() is a trigonometric helper in the sass:math module. It returns the sine of an angle—useful for circular layouts, wave-like tokens, and fixed transform factors. You will learn angle units, the unitless-as-radians rule, Dart Sass 1.25+ notes, and five compiled examples.
01
Concept
Sine
02
Module
@use "sass:math"
03
Angles
deg / rad / unitless
04
Result
Unitless ratio
05
Since
Dart Sass 1.25+
06
Practice
5 examples
Concept
What Is math.sin()?
Sine relates an angle to a vertical factor on the unit circle. In Sass it returns that factor as a unitless number (usually between -1 and 1):
math.sin(100deg) → about 0.984807753
math.sin(1rad) → about 0.8414709848
math.sin(1) → same as 1rad (unitless = radians)
math.sin(0deg) → 0 · math.sin(90deg) → 1
Official docs place it under Trigonometric Functions with math.cos(), math.tan, and the inverse helpers. Pair sine with a radius to place points: $y: $r * math.sin($angle).
💡
Beginner tip
Browsers never see math.sin. Dart Sass evaluates it and writes a plain number into your .css file. Prefer writing deg when you think in degrees—unitless 1 means 1 radian, not 1 degree.
Foundation
📝 Syntax
Load the math module, then pass an angle or a unitless radian value:
styles.scss
@use "sass:math";
math.sin($number)
// angle (deg-compatible) or unitless → radians
Parameters
Parameter
Type
Required
Description
$number
Number
Yes
An angle whose units are compatible with deg (e.g. deg, rad, turn, grad), or a unitless number treated as radians.
Return value
Type
Situation
Result
Number
Valid angle or unitless radian
Unitless sine (typically −1…1)
Error
Incompatible units (e.g. px)
Compile fails—pass an angle, not a length
Modules
📦 Loading sass:math
styles.scss
// Recommended — namespaced
@use "sass:math";
$s: math.sin(30deg);
// Optional — bring members into the current namespace
@use "sass:math" as *;
$s: sin(30deg);
// Optional — custom namespace
@use "sass:math" as m;
$s: m.sin(30deg);
⚠️
Put @use first
Keep @use "sass:math"; near the top of the file. math.sin() needs Dart Sass 1.25+.
Numbers
📏 How Units Work
Pass an angle, or omit units to mean radians. The result is always unitless—multiply by a length when you need CSS lengths.
Call
Result (approx.)
Notes
math.sin(100deg)
0.984807753
Official example
math.sin(1rad)
0.8414709848
Official example
math.sin(1)
0.8414709848
Unitless = radians
math.sin(0deg)
0
No vertical factor
math.sin(90deg)
1
Full vertical factor
80px * math.sin(30deg)
40px
Reattach a length after sin
math.sin(10px)
—
Error: not an angle
Support
🛠 Compatibility
This is about Sass compilers, not browsers. Compiled CSS receives a plain number.
Implementation
math.sin()
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";
Sine in degrees
math.sin(100deg)
Sine in radians
math.sin(1rad) or math.sin(1)
Y offset on a circle
$r * math.sin($angle)
Use π from the module
math.sin(math.$pi) ≈ 0
Debug while learning
@debug math.sin(30deg);
Compare
📋 sin vs cos vs tan
Function
What it returns
Common use
math.sin($angle)
Vertical / opposite factor
Y on a circle, wave-like tokens
math.cos($angle)
Horizontal / adjacent factor
X on a circle, soft falloff from an angle
math.tan($angle)
Slope ratio sin/cos
Angles of incline, skewed offsets
All three share the same input rules: angle units, or unitless radians. For a point on a circle: $x: $r * math.cos($a) and $y: $r * math.sin($a).
Compare
📋 Sass math.sin() vs CSS / JS sin
Sass math.sin()
CSS sin() / JS Math.sin
When it runs
Compile time (Dart Sass)
In the browser / runtime
Appears in CSS output?
No — only the numeric result
CSS sin() can stay in the stylesheet
Unitless input
Treated as radians
JS: radians; CSS: follows CSS angle rules
Best for
Fixed angles known in SCSS
Dynamic angles, animated custom properties
Hands-On
Examples Gallery
Each example uses @use "sass:math". Open View Compiled CSS to see what Dart Sass emits.
Perfect values like 0.5 and 1 compile cleanly. 180deg and math.$pi are effectively 0 within Sass precision.
Example 3 — Unitless Means Radians
A common beginner trap: forgetting that bare numbers are radians.
styles.scss
@use "sass:math";
.compare {
// These match (1 radian)
--as-rad: #{math.sin(1rad)};
--unitless: #{math.sin(1)};
// This is different (1 degree)
--as-deg: #{math.sin(1deg)};
}
Expecting an angle back — sine is a ratio, not deg.
Old Dart Sass — need 1.25+; LibSass lacks the module API.
Pro Tips
💡 Best Practices
✅ Do
Use @use "sass:math" and math.sin() in new SCSS
Write deg (or rad) explicitly for clarity
Multiply by a length when you need CSS offsets
Pair with math.cos() for full circular coordinates
Prefer Dart Sass 1.25+
❌ Don’t
Assume unitless means degrees
Pass px / rem into math.sin
Expect the browser to re-evaluate math.sin
Use Sass sin for animated angles (prefer CSS sin())
Rely on LibSass for sass:math
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about math.sin()
Compile-time sine—angles in, unitless ratio out.
5
Core concepts
📝01
Call
math.sin($angle)
API
📦02
Module
sass:math
@use
🌡️03
Unitless
= radians
Rule
🔢04
Result
unitless ratio
Output
⚡05
Since
Dart Sass 1.25+
Tooling
❓ Frequently Asked Questions
math.sin($number) returns the sine of an angle. Example: math.sin(100deg) is about 0.984807753; math.sin(1rad) and math.sin(1) are about 0.8414709848.
Add @use "sass:math"; then call math.sin($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. Sine is a unitless ratio (typically between -1 and 1). Multiply by a length if you need a CSS length, for example $r * math.sin(30deg).
Sass math.sin() runs at compile time and writes a fixed number. CSS sin() stays in the stylesheet and can use runtime values like custom properties in supporting browsers.
Official docs expose this as math.sin() on sass:math. Prefer the module form with @use "sass:math".
Did you know?
Official Sass docs note that if $number has no units, it is assumed to be in rad. That is why math.sin(1) and math.sin(1rad) print the same value in the documentation examples.
math.sin() gives you compile-time sine for known angles. Prefer explicit deg or rad, remember that unitless means radians, and multiply by a length when you need CSS offsets. Pair it with math.cos for full circular layout math.