Sass math.sin() Function

Beginner
⏱️ 12 min read
📚 Updated: Jul 2026
🎯 5 Examples
sass:math · Dart Sass 1.25+

What You’ll Learn

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

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.

📝 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

ParameterTypeRequiredDescription
$numberNumberYesAn angle whose units are compatible with deg (e.g. deg, rad, turn, grad), or a unitless number treated as radians.

Return value

TypeSituationResult
NumberValid angle or unitless radianUnitless sine (typically −1…1)
ErrorIncompatible units (e.g. px)Compile fails—pass an angle, not a length

📦 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+.

📏 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.

CallResult (approx.)Notes
math.sin(100deg)0.984807753Official example
math.sin(1rad)0.8414709848Official example
math.sin(1)0.8414709848Unitless = radians
math.sin(0deg)0No vertical factor
math.sin(90deg)1Full vertical factor
80px * math.sin(30deg)40pxReattach a length after sin
math.sin(10px)Error: not an angle

🛠 Compatibility

This is about Sass compilers, not browsers. Compiled CSS receives a plain number.

Implementationmath.sin()Notes
Dart Sass 1.25+YesPreferred; needs @use "sass:math"
Dart Sass < 1.25NoUpgrade Dart Sass
LibSass / Ruby SassNo module APIUse Dart Sass for trigonometric helpers

⚡ Quick Reference

GoalCode
Import math@use "sass:math";
Sine in degreesmath.sin(100deg)
Sine in radiansmath.sin(1rad) or math.sin(1)
Y offset on a circle$r * math.sin($angle)
Use π from the modulemath.sin(math.$pi)0
Debug while learning@debug math.sin(30deg);

📋 sin vs cos vs tan

FunctionWhat it returnsCommon use
math.sin($angle)Vertical / opposite factorY on a circle, wave-like tokens
math.cos($angle)Horizontal / adjacent factorX on a circle, soft falloff from an angle
math.tan($angle)Slope ratio sin/cosAngles 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).

📋 Sass math.sin() vs CSS / JS sin

Sass math.sin()CSS sin() / JS Math.sin
When it runsCompile time (Dart Sass)In the browser / runtime
Appears in CSS output?No — only the numeric resultCSS sin() can stay in the stylesheet
Unitless inputTreated as radiansJS: radians; CSS: follows CSS angle rules
Best forFixed angles known in SCSSDynamic angles, animated custom properties

Examples Gallery

Each example uses @use "sass:math". Open View Compiled CSS to see what Dart Sass emits.

📚 Getting Started

Official-style deg/rad calls and familiar angles.

Example 1 — Basic math.sin()

Official docs examples with degrees and radians.

styles.scss
@use "sass:math";

@debug math.sin(100deg); // 0.984807753
@debug math.sin(1rad);   // 0.8414709848
@debug math.sin(1);      // 0.8414709848

.demo {
  --sin-100deg: #{math.sin(100deg)};
  --sin-1rad: #{math.sin(1rad)};
}

How It Works

Degrees and radians are both valid angle inputs. Unitless 1 matches 1rad, not 1deg.

Example 2 — Common Angles

Memorize a few landmarks: 0°, 30°, 90°, 180°.

styles.scss
@use "sass:math";

.landmarks {
  --s0: #{math.sin(0deg)};     // 0
  --s30: #{math.sin(30deg)};   // 0.5
  --s90: #{math.sin(90deg)};   // 1
  --s180: #{math.sin(180deg)}; // ~0
  --spi: #{math.sin(math.$pi)}; // ~0 (π radians)
}

How It Works

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)};
}

How It Works

Write deg when you mean degrees. Leaving units off is the same as writing rad.

📈 Practical Patterns

Circular offsets and sine-based soft factors.

Example 4 — Y Offset on a Circle

Place an element along a fixed radius using sine for the vertical component.

styles.scss
@use "sass:math";

$r: 80px;
$angle: 30deg;

.orbit-item {
  // y = r · sin(θ)
  top: 50% + $r * math.sin($angle);
  // pair with cos for x: $r * math.cos($angle)
  --sin: #{math.sin($angle)};
}

How It Works

math.sin(30deg) is 0.5. Multiplying by 80px gives a 40px vertical offset; Sass may emit calc() when mixing % and px.

Example 5 — Soft Factor from an Angle

Map sine into a 0–1 range for a gentle opacity or translate token.

styles.scss
@use "sass:math";

// sin goes -1…1 → shift to 0…1
$angle: 30deg;
$factor: (math.sin($angle) + 1) / 2;

.soft {
  opacity: $factor;
  transform: translateY(#{(1 - $factor) * 12px});
}

How It Works

math.sin(30deg) is 0.5. Adding 1 and dividing by 2 yields 0.75. The translate uses the leftover 0.25 × 12px = 3px.

🚀 Real-World Use Cases

  • Circular menus — compute fixed y positions with $r * math.sin($angle).
  • Icon / badge rings — place known steps around a circle with cos for x and sin for y.
  • Soft fades — map sine into 0–1 for opacity or motion tokens.
  • Wave-like spacing — bake vertical projection into translate or margin.
  • Teaching trig — show deg vs rad vs unitless with @debug.
  • Fixed vs animated — use Sass when the angle is known; use CSS sin() when it must animate.

🧠 How Compilation Works

1

Write SCSS

Call math.sin($angle) after @use.

Source
2

Check angle units

Accept deg-compatible angles; treat unitless as radians.

Validate
3

Compute sine

Return a unitless number (typically between −1 and 1).

Sin
4

Plain CSS ships

The browser only receives the final number (or a length you rebuild).

⚠️ Common Pitfalls

  • Unitless ≠ degrees — bare numbers are radians; write deg when you mean degrees.
  • Passing lengthsmath.sin(10px) fails; pass an angle, then multiply by a length.
  • Forgetting @usemath.sin needs sass:math loaded.
  • Expecting an angle back — sine is a ratio, not deg.
  • Old Dart Sass — need 1.25+; LibSass lacks the module API.

💡 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

Key Takeaways

Knowledge Unlocked

Five things to remember about math.sin()

Compile-time sine—angles in, unitless ratio out.

5
Core concepts
📦 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.

Conclusion

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.

Continue with math.cos(), math.sqrt(), or the Sass introduction.

More Sass Math

Continue with square roots in the math module.

math.sqrt() →

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.

5 people found this page helpful