Sass meta.calc-name()

Intermediate
8 min read
Updated: Nov 2026
5 examples
Dart Sass 1.40+

Definition and Usage

meta.calc-name($calc) returns the quoted string name of a CSS calculation value—for example "calc" or "clamp". Load it with @use "sass:meta" on Dart Sass 1.40+.

Official samples.

meta.calc-name(calc(100px + 10%)) → "calc" · meta.calc-name(clamp(50px, var(--width), 1000px)) → "clamp".

Branch on kind.

Compare with quoted strings: meta.calc-name($value) == "clamp". Pair with meta.calc-args when you also need the argument list.

Not for plain lengths.

10px is a number, not a calculation. Pass a calc / clamp / min / max value.

Syntax

SCSS
@use "sass:meta";

meta.calc-name($calc); //=> quoted string

meta.calc-name(calc(100px + 10%));              // "calc"
meta.calc-name(clamp(50px, var(--width), 1000px)); // "clamp"
meta.calc-name(min(100px, 10%));                // "min"
meta.calc-name(max(1rem, 2vw));                 // "max"

// Module API — prefer meta.calc-name after @use "sass:meta"

Pattern: capture a calculation → read the name → branch or log → use meta.calc-args for the contents.

Names and Pairing

Common names and how they differ from args:

Inputcalc-nameUsually pair with
calc(...)"calc"One expression arg via calc-args
clamp(...)"clamp"Three args (min / preferred / max)
min(...)"min"Two or more comparable values
max(...)"max"Two or more comparable values
Quoted for compares.

Official return is a quoted string, so == "clamp" works cleanly. Interpolation into custom properties may drop the quotes in CSS output.

SCSS Examples

Examples target Dart Sass 1.40+ with @use "sass:meta". Open View Compiled CSS for verified output (official samples use @debug; demos also emit via content to keep quotes visible).

Example 1 — Official Docs Sample (calc)

Name of a calc() value is "calc".

SCSS
@use "sass:meta";

@debug meta.calc-name(calc(100px + 10%)); // "calc"

.basic {
  content: meta.calc-name(calc(100px + 10%));
}

How It Works

  1. Input is a calculation value.
  2. Return is the quoted string "calc".
  3. content keeps the quotes in CSS.
  4. Matches the official Sass docs sample.

Example 2 — Official Docs Sample (clamp)

Name of a clamp() value is "clamp".

SCSS
@use "sass:meta";

@debug meta.calc-name(clamp(50px, var(--width), 1000px)); // "clamp"

.clamp-demo {
  content: meta.calc-name(clamp(50px, var(--width), 1000px));
}

How It Works

  1. Input is a clamp calculation.
  2. Name is "clamp".
  3. Arguments are separate—use calc-args for those.
  4. Matches the official Sass docs sample.

Example 3 — min() and max()

Same helper names other CSS calculation functions.

SCSS
@use "sass:meta";

.min-demo {
  content: meta.calc-name(min(100px, 10%));
}

.max-demo {
  content: meta.calc-name(max(1rem, 2vw));
}

How It Works

  1. min(...) → "min".
  2. max(...) → "max".
  3. Same API as calc and clamp.
  4. Useful in shared validation helpers.

Example 4 — Branch on Calculation Kind

Compare the quoted name in @if.

SCSS
@use "sass:meta";
@use "sass:list";

$value: clamp(50px, var(--width), 1000px);

.branch {
  @if meta.calc-name($value) == "clamp" {
    --kind: clamp;
    --count: #{list.length(meta.calc-args($value))};
  }
}

How It Works

  1. Compare against "clamp".
  2. Branch runs for clamp values.
  3. Then read the argument count.
  4. Compile-time only—browsers never see the @if.

Example 5 — Pair with meta.calc-args

Describe both the function name and how many args it carries.

SCSS
@use "sass:meta";
@use "sass:list";

$value: clamp(50px, var(--width), 1000px);

.pair {
  content: meta.calc-name($value);
  --count: #{list.length(meta.calc-args($value))};
}

How It Works

  1. calc-name answers which function.
  2. calc-args answers what was passed.
  3. Together they describe the calculation.
  4. Handy in debug mixins and token validators.

Edge Cases & Pitfalls

Most calc-name bugs are passing plain numbers or forgetting quotes in compares.

input

Needs a calculation value

Plain 10px is not valid. Pass calc, clamp, min, or max.

compare

Compare with quoted strings

Write == "clamp", not an unquoted identifier, when branching on the name.

args

Name ≠ arguments

Use meta.calc-args when you need the values inside.

interpolate

Custom properties drop quotes

--n: #{meta.calc-name(...)} often emits clamp without quotes. Use content or keep the Sass string for logic.

Sass Support

Prefer the module form with Dart Sass 1.40+.

APIStatus
meta.calc-name()Dart Sass 1.40+ via @use "sass:meta"
InputCalculation value (calc / clamp / min / max)
Return typeQuoted string
LibSass / Ruby SassNot available

Compile with the Dart Sass CLI.

Key Takeaways

  • Returns a quoted name like "calc" or "clamp".
  • Branch with == "clamp" at compile time.
  • Pair with calc-args for the argument list.
  • Dart Sass 1.40+ via @use "sass:meta".

One line: when you need the function name of a CSS calculation at compile time, call meta.calc-name($calc).

Compile Notes

Practical checklist:

checklist.txt
1. @use "sass:meta"
2. Pass a calc / clamp / min / max value
3. Expect a quoted string name
4. Compare with == "clamp" (quoted)
5. Use meta.calc-args for the contents

Frequently Asked Questions

meta.calc-name($calc) returns the name of a CSS calculation value as a quoted string—for example "calc" or "clamp". Use it to branch on calculation kind at compile time.
meta.calc-name returns the function name ("clamp"). meta.calc-args returns the list of arguments inside that calculation. Use both together when you need kind and contents.
Common values include "calc", "clamp", "min", and "max"—whatever CSS calculation kind Sass stored. Official samples show "calc" and "clamp".
Yes. Official docs return a quoted string such as "calc". That makes string compares like meta.calc-name($c) == "clamp" straightforward.
No. Pass a calculation value. Plain lengths like 10px are numbers, not calculations—use calc()/clamp()/min()/max() first.
Dart Sass 1.40+. LibSass and Ruby Sass do not provide this helper. Prefer current Dart Sass.

Next: Sass meta.call()

Invoke a function value dynamically with arguments.

meta.call() →

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.

8 people found this page helpful