Sass math.asin() Function

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

What You’ll Learn

math.asin() is an inverse trigonometric helper in the sass:math module. Given a sine factor, it returns the matching angle in deg. You will learn the unitless input rule, NaNdeg behavior, pairing with math.sin, Dart Sass 1.25+ notes, and five compiled examples.

01

Concept

Arcsine

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

What Is math.asin()?

Arcsine answers: which angle has this sine? In Sass the answer is always an angle in degrees:

  • math.asin(0.5)30deg
  • math.asin(0)0deg · math.asin(1)90deg · math.asin(-1)-90deg
  • math.asin(2)NaNdeg (outside the sine range)

Official docs place it under Trigonometric Functions next to math.sin(), math.acos(), and math.atan. Use asin when you already have a unitless sine factor and need the angle back.

💡
Beginner tip

Browsers never see math.asin. Dart Sass evaluates it and writes a plain angle (like 30deg) into your .css file—or NaNdeg if the input was invalid.

📝 Syntax

Load the math module, then pass a unitless number:

styles.scss
@use "sass:math";

math.asin($number)
// $number must be unitless → result is in deg

Parameters

ParameterTypeRequiredDescription
$numberNumberYesSine factor. Must be unitless. Valid domain is typically -1 to 1.

Return value

TypeSituationResult
AngleInput in −1…1Arcsine in deg (−90deg…90deg)
AngleInput outside −1…1NaNdeg (as in the official docs)
ErrorArgument has unitsCompile fails—pass a unitless factor

📦 Loading sass:math

styles.scss
// Recommended — namespaced
@use "sass:math";
$a: math.asin(0.5);

// Optional — bring members into the current namespace
@use "sass:math" as *;
$a: asin(0.5);

// Optional — custom namespace
@use "sass:math" as m;
$a: m.asin(0.5);
⚠️
Put @use first

Keep @use "sass:math"; near the top of the file. math.asin() needs Dart Sass 1.25+.

📏 How Units Work

Unlike math.sin() (which takes an angle), math.asin() takes a unitless factor and returns deg.

CallResultNotes
math.asin(0.5)30degOfficial example
math.asin(2)NaNdegOfficial out-of-range example
math.asin(0)0degSine of 0°
math.asin(1)90degSine of 90°
math.asin(-1)-90degSine of −90°
math.asin(0.5px)Error: must be unitless

🛠 Compatibility

This is about Sass compilers, not browsers. Compiled CSS receives a plain angle (or NaNdeg).

Implementationmath.asin()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";
Angle from sinemath.asin(0.5)30deg
Out of rangemath.asin(2)NaNdeg
Clamp before asinmath.asin(math.clamp(-1, $n, 1))
Round-trip with sinmath.sin(math.asin(0.5))0.5
Debug while learning@debug math.asin(0.5);

📋 asin vs sin vs acos

FunctionDirectionBest for
math.asin($n)Factor → angle (deg)Recovering an angle from a sine factor
math.sin($angle)Angle → unitless factorVertical projection / circular Y
math.acos($n)Factor → angle (deg)Recovering an angle from a cosine factor

Prefer math.asin when the known value is a sine-like ratio. Prefer math.sin when you already know the angle. Note the ranges: asin spans −90deg…90deg; acos spans 0deg…180deg.

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

Sass math.asin()CSS asin() / JS Math.asin
When it runsCompile time (Dart Sass)In the browser / runtime
Result unitAlways degJS returns radians; CSS follows CSS angle rules
Appears in CSS output?No — only the angle resultCSS asin() can stay in the stylesheet
Best forFixed factors known in SCSSDynamic factors / animated values

Examples Gallery

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

📚 Getting Started

Official-style asin calls and landmark values.

Example 1 — Basic math.asin()

Official docs example: arcsine of 0.5 is 30 degrees.

styles.scss
@use "sass:math";

@debug math.asin(0.5); // 30deg

.demo {
  --angle: #{math.asin(0.5)};
  rotate: math.asin(0.5);
}

How It Works

Sine of 30° is 0.5, so arcsine of 0.5 is 30deg. The result is already an angle unit you can use in CSS.

Example 2 — Landmark Factors

Memorize the endpoints and the midpoint of the sine range.

styles.scss
@use "sass:math";

.landmarks {
  --a0: #{math.asin(0)};   // 0deg
  --a1: #{math.asin(1)};   // 90deg
  --am1: #{math.asin(-1)}; // -90deg
}

How It Works

Valid asin results span -90deg to 90deg—the principal range of arcsine (different from acos, which spans 0deg…180deg).

Example 3 — Out of Range Returns NaNdeg

Official docs show that values outside −1…1 are not real arcsines.

styles.scss
@use "sass:math";

@debug math.asin(2); // NaNdeg

.guard {
  --bad: #{math.asin(2)};
  --ok: #{math.asin(0.5)};
}

How It Works

Sine never produces 2, so math.asin(2) becomes NaNdeg. Clamp inputs in real tokens (see example 5).

📈 Practical Patterns

Round-trips with sin and safe clamping.

Example 4 — Round-Trip with math.sin()

Recover a factor from an angle, or an angle from a factor.

styles.scss
@use "sass:math";

$factor: 0.5;
$angle: math.asin($factor);          // 30deg
$back: math.sin($angle);            // ~0.5

.orbit {
  rotate: $angle;
  --factor: #{$back};
}

How It Works

math.asin and math.sin undo each other for values in the valid sine range (within Sass floating-point precision).

Example 5 — Clamp Before asin

Keep noisy design tokens inside −1…1 so you never ship NaNdeg.

styles.scss
@use "sass:math";

$raw: 1.2; // oops — slightly out of range
$safe: math.clamp(-1, $raw, 1);
$angle: math.asin($safe); // 90deg

.safe-rotate {
  rotate: $angle;
  --raw: #{$raw};
  --safe: #{$safe};
}

How It Works

math.clamp() pins 1.2 to 1, and math.asin(1) is 90deg instead of NaNdeg.

🚀 Real-World Use Cases

  • Recover angles — turn a stored sine factor back into deg for rotate.
  • Design-token bridges — authors edit ratios; Sass emits angles.
  • Round-trip checks — validate that sin ↔ asin stay consistent in a scale.
  • Safe geometry — clamp factors before asin to avoid NaNdeg.
  • Teaching inverse trig — show how asin undoes sin with @debug.
  • Fixed vs animated — use Sass when the factor is known; use CSS asin() when it must change at runtime.

🧠 How Compilation Works

1

Write SCSS

Call math.asin($number) after @use.

Source
2

Require unitless

Sass rejects lengths; the value must be a bare number.

Validate
3

Compute arcsine

Return an angle in deg, or NaNdeg if out of range.

Asin
4

Plain CSS ships

The browser only receives the final angle (e.g. 30deg).

⚠️ Common Pitfalls

  • Passing angles into asin — input is a unitless factor, not deg.
  • Out-of-range factors — values outside −1…1 become NaNdeg.
  • Expecting radians — Sass asin always returns deg (unlike JS Math.asin).
  • Confusing with acos range — asin is −90…90; acos is 0…180.
  • Old Dart Sass — need 1.25+; LibSass lacks the module API.

💡 Best Practices

✅ Do

  • Use @use "sass:math" and math.asin() in new SCSS
  • Keep inputs unitless and inside −1…1
  • Clamp noisy tokens with math.clamp(-1, $n, 1)
  • Pair with math.sin() for round-trips
  • Prefer Dart Sass 1.25+

❌ Don’t

  • Pass px / deg into math.asin
  • Ship NaNdeg from unvalidated factors
  • Expect the browser to re-evaluate math.asin
  • Assume JS-style radian output
  • Rely on LibSass for sass:math

Key Takeaways

Knowledge Unlocked

Five things to remember about math.asin()

Compile-time arcsine—unitless factor in, deg out.

5
Core concepts
📦 02

Module

sass:math

@use
🔢 03

Input

unitless

Rule
🌡️ 04

Output

−90°…90°

Angle
05

Since

Dart Sass 1.25+

Tooling

❓ Frequently Asked Questions

math.asin($number) returns the arcsine of a unitless number in degrees. Example: math.asin(0.5) is 30deg; math.asin(2) is NaNdeg.
Add @use "sass:math"; then call math.asin($number). Requires Dart Sass 1.25+.
A unitless number, typically between -1 and 1 (the range of sine). Lengths like px are not allowed.
An angle in deg. For valid inputs the result is between -90deg and 90deg. Out-of-range inputs return NaNdeg.
They are inverse ideas: math.sin(math.asin(0.5)) recovers about 0.5, and math.asin(math.sin(30deg)) recovers 30deg (within floating-point precision).
Official docs expose this as math.asin() on sass:math. Prefer the module form with @use "sass:math".
Did you know?

Official Sass docs show math.asin(2) as NaNdeg—not a bare NaN. The deg unit stays attached even when the numeric part is not a number.

Conclusion

math.asin() turns a unitless sine factor into a compile-time angle in deg (−90°…90°). Keep inputs in −1…1 (clamp when needed), pair with math.sin for round-trips, and watch for NaNdeg on invalid values.

Continue with math.sin(), math.atan(), or math.acos().

More Sass Math

Continue with arctangent in the math module.

math.atan() →

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