Home Sass Math math.asin() Sass math.asin() Definition
Definition and Usage math.asin($number) returns the arcsine of $number in deg . $number must be unitless . Load it with @use "sass:math" on Dart Sass 1.25+ .
Official samples. math.asin(0.5) → 30deg. math.asin(2) is out of range (docs show NaNdeg; current Dart Sass emits calc(NaN * 1deg)).
Inverse of sine. Valid results sit between -90deg and 90deg. Pair with math.sin for round-trips. Compare with math.acos (0…180deg).
Unitless input only. Do not pass px, %, or deg into math.asin. Feed a plain sine ratio (about -1 to 1).
Syntax
Syntax @use "sass:math";
math.asin($number); //=> angle in deg
math.asin(0.5); // 30deg
math.asin(1); // 90deg
math.asin(0); // 0deg
math.asin(-0.5); // -30deg
math.asin(-1); // -90deg
math.asin(2); // NaN angle (out of range)
// Module API — prefer math.asin after @use "sass:math" Pattern: compute a sine ratio → math.asin for a signed CSS angle → compare with math.acos / math.atan when the geometry differs.
Code
SCSS Examples Examples target Dart Sass 1.25+ with @use "sass:math". Open View Compiled CSS for verified output (matches official Sass docs samples).
1. Basic 2. Key angles 3. Out of range 4. Round-trip 5. CSS angle Example 1 — Official Docs Sample Arcsine of 0.5 is a 30° angle.
@use "sass:math";
@debug math.asin(0.5); // 30deg
.basic {
--half: #{math.asin(0.5)};
} .basic {
--half: 30deg;
} How It Works Unitless 0.5 is a valid sine value.Result is 30deg , not radians.Ready for CSS properties that take angles.Matches the official Sass docs sample.Example 2 — Endpoints and Signs Map 1, 0, and negative ratios to classic angles.
@use "sass:math";
.range {
--one: #{math.asin(1)};
--zero: #{math.asin(0)};
--neg-half: #{math.asin(-0.5)};
--neg: #{math.asin(-1)};
} .range {
--one: 90deg;
--zero: 0deg;
--neg-half: -30deg;
--neg: -90deg;
} How It Works asin(1) → 90deg.asin(0) → 0deg.Negative inputs yield negative degrees.Range is -90…90deg for real results.Example 3 — Out-of-Range Input Sine never exceeds 1, so 2 is invalid.
@use "sass:math";
@debug math.asin(2); // NaN angle (docs: NaNdeg)
.nan {
--bad: #{math.asin(2)};
} .nan {
--bad: calc(NaN * 1deg);
} How It Works |x| > 1 is outside the sine domain.Official docs label the result NaNdeg.Current Dart Sass serializes it as calc(NaN * 1deg).Clamp or guard inputs before calling asin in real themes.Example 4 — Round-Trip with math.sin asin and sin undo each other for valid values.
@use "sass:math";
.roundtrip {
--back-num: #{math.sin(math.asin(0.5))};
--back-ang: #{math.asin(math.sin(30deg))};
--acos: #{math.acos(0.5)};
} .roundtrip {
--back-num: 0.5;
--back-ang: 30deg;
--acos: 60deg;
} How It Works sin(asin(0.5)) recovers 0.5.asin(sin(30deg)) recovers 30deg.acos(0.5) is 60deg — a different inverse.Pick asin vs acos based on which trig ratio you have.Example 5 — Emit a CSS Rotation Turn a sine ratio into a concrete rotate() angle.
@use "sass:math";
$sin: 0.5;
.angle {
--deg: #{math.asin($sin)};
transform: rotate(math.asin($sin));
} .angle {
--deg: 30deg;
transform: rotate(30deg);
} How It Works Store the ratio in a variable when reusing it.Sass compiles the angle before CSS sees it.transform receives plain 30deg.Useful for geometry helpers in design systems. Edge Cases & Pitfalls Most asin bugs are feeding units, or skipping the −1…1 domain check.
units Input must be unitless math.asin(0.5deg) or math.asin(0.5px) fails. Pass a plain number.
domain Clamp before calling If a ratio can drift past ±1 from rounding, clamp it first (for example with math.clamp(-1, $x, 1)).
nan NaN serialization Docs say NaNdeg; modern Dart Sass may emit calc(NaN * 1deg). Treat both as invalid angles.
range asin ≠ acos range asin returns -90…90deg; acos returns 0…180deg. Same ratio can mean different angles.
Toolchain
Sass Support Prefer the module form with Dart Sass 1.25+.
API Status math.asin()Dart Sass 1.25+ via @use "sass:math" Input Unitless number Return type Angle in deg (or NaN angle) LibSass / Ruby Sass No modern sass:math asin
Compile with the Dart Sass CLI .
Remember
Key Takeaways Returns arcsine in deg from a unitless sine ratio.
Valid domain is -1…1 ; range is -90deg…90deg.
Pairs with math.sin for inverse trigonometry.
Dart Sass 1.25+ via @use "sass:math".
One line: when a unitless sine ratio must become a CSS angle, call math.asin($number).
Practice
Compile Notes Practical checklist:
1. @use "sass:math"
2. Pass a unitless ratio in -1…1
3. Expect a deg angle (-90deg…90deg)
4. Clamp noisy inputs before asin
5. Use math.sin for the forward transform Frequently Asked Questions What does Sass math.asin() do? math.asin($number) returns the arcsine of a unitless number in degrees. Example: math.asin(0.5) is 30deg. Values outside -1…1 are not a real angle; current Dart Sass emits calc(NaN * 1deg) for those.
How do I use math.asin() with @use? Add @use "sass:math"; then call math.asin($number). Requires Dart Sass 1.25+.
What input does math.asin() accept? A unitless number, typically between -1 and 1 (the range of sine). Lengths like px or angles like deg are not allowed as input.
What does math.asin() return? An angle in deg. For valid inputs the result is between -90deg and 90deg. Out-of-range inputs produce a NaN angle (serialized as calc(NaN * 1deg) in modern Dart Sass).
How is math.asin related to math.sin? They are inverse ideas: math.sin(math.asin(0.5)) recovers 0.5, and math.asin(math.sin(30deg)) recovers 30deg (within floating-point precision).
Is there a global asin() in Sass? Official docs expose this as math.asin() on sass:math. Prefer the module form with @use "sass:math".
Next: Sass math.atan() Return the arctangent of a unitless number in degrees.
math.atan() → About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
8 people found this page helpful
Helpful Share Copy link Suggestion