Sass meta.calc-name() Function

Intermediate
⏱️ 10 min read
📚 Updated: Jul 2026
🎯 5 Examples
sass:meta · Dart Sass 1.40+

What You’ll Learn

meta.calc-name() belongs to the built-in sass:meta module. It returns the quoted name of a CSS calculation value—for example "calc" or "clamp". This page covers branching on kind, pairing with meta.calc-args, Dart Sass 1.40+, and five compiled examples.

01

Concept

Name the calculation

02

Module

@use "sass:meta"

03

Returns

Quoted string

04

Examples

"calc" / "clamp"

05

With args

meta.calc-args

06

Practice

5 examples

What Is meta.calc-name()?

Sass stores values like calc(100% - 2rem) and clamp(1rem, 2vw, 3rem) as a special calculation type. Sometimes you need to know which calculation it is before you inspect arguments or rebuild CSS. Official docs: meta.calc-name($calc) returns the name of the given calculation.

  • Result is a quoted string (for example "calc")
  • Works with common CSS calc functions Sass understands (calc, clamp, min, max, …)
  • Ideal for @if branches in design-token helpers
💡
Beginner tip

Think of reading the label on a box. meta.calc-name says "clamp"; meta.calc-args lists what is inside the box.

📝 Syntax

Load the meta module, then call the function:

styles.scss
@use "sass:meta";

meta.calc-name($calc)

Parameters

ParameterTypeRequiredDescription
$calcCalculationYesA CSS calculation value such as calc(...), clamp(...), min(...), or max(...).

Return value

TypeResult
Quoted stringThe calculation’s name—for example "calc" or "clamp"

📦 Loading sass:meta

styles.scss
// Recommended — namespaced
@use "sass:meta";
$name: meta.calc-name(clamp(1rem, 2vw, 3rem)); // "clamp"

// Optional — bring members into scope
@use "sass:meta" as *;
$name: calc-name(clamp(1rem, 2vw, 3rem));

// Optional — custom namespace
@use "sass:meta" as m;
$name: m.calc-name(clamp(1rem, 2vw, 3rem));

🔢 Official Samples

From the Sass docs, the return values are quoted strings:

styles.scss
@use "sass:meta";

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

📋 meta.calc-name vs meta.calc-args

meta.calc-namemeta.calc-args
ReturnsQuoted name stringList of arguments
Best for@if on kindReading / transforming inputs
Example"clamp"50px, var(--width), 1000px
SinceDart Sass 1.40+Dart Sass 1.40+

🛠 Compatibility

This is about Sass compilers, not browsers. The name is resolved at compile time; browsers only see CSS you emit.

Implementationmeta.calc-name()Notes
Dart Sass (1.40+)Yes — requiredCalculation introspection helpers
LibSassNoNo modern calc meta API
Ruby SassNoLegacy—prefer Dart Sass

⚡ Quick Reference

GoalCode
Import meta@use "sass:meta";
Get namemeta.calc-name($calc)
Compare kindmeta.calc-name($calc) == "clamp"
List argumentsmeta.calc-args($calc)
Minimum Dart Sass1.40+

Examples Gallery

Each example uses @use "sass:meta". Open View Compiled CSS for verified output (official samples where noted).

📚 Getting Started

Official docs samples for calc and clamp.

Example 1 — Name of calc() (Official Docs)

Returns the quoted string "calc".

styles.scss
@use "sass:meta";

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

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

How It Works

Sass recognizes the value as a calculation named calc. Interpolation into CSS drops the quotes, so the custom property shows calc.

Example 2 — Name of clamp() (Official Docs)

Returns the quoted string "clamp".

styles.scss
@use "sass:meta";

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

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

How It Works

Same idea as Example 1: the calculation kind is clamp, returned as "clamp".

📈 Practical Patterns

Branching, pairing with calc-args, and min/max tokens.

Example 3 — Branch on Calculation Kind

Handle fluid clamp tokens differently from simple calc tokens.

styles.scss
@use "sass:meta";

@function describe-size($size) {
  @if meta.calc-name($size) == "clamp" {
    @return "fluid";
  } @else if meta.calc-name($size) == "calc" {
    @return "computed";
  } @else {
    @return "other";
  }
}

$a: clamp(1rem, 2vw, 2rem);
$b: calc(100% - 2rem);

.box {
  --a: #{describe-size($a)};
  --b: #{describe-size($b)};
  font-size: $a;
  width: $b;
}

How It Works

Quoted-string compares like == "clamp" keep token helpers readable without stringifying the whole calculation.

Example 4 — Pair Name with Arguments

Emit both the kind and the inspected argument list for documentation tokens.

styles.scss
@use "sass:meta";

$fluid: clamp(1rem, 2vw + 0.5rem, 2rem);

.token {
  --kind: #{meta.calc-name($fluid)};
  --args: #{meta.inspect(meta.calc-args($fluid))};
  font-size: $fluid;
}

How It Works

calc-name labels the token; calc-args exposes the three clamp pieces for themes or style guides.

Example 5 — min() and max() Names

Same API works for other calculation kinds Sass stores.

styles.scss
@use "sass:meta";

$cap: min(90vw, 40rem);
$floor: max(12px, 0.8rem);

.layout {
  --cap-kind: #{meta.calc-name($cap)};
  --floor-kind: #{meta.calc-name($floor)};
  max-width: $cap;
  font-size: $floor;
}

How It Works

Each value keeps its CSS calculation in the property, while custom properties record the compile-time names min and max.

🚀 Real-World Use Cases

  • Token classifiers — mark sizes as fluid (clamp) vs computed (calc).
  • Validation — require clamp tokens before generating fluid-type utilities.
  • Docs / debug CSS — emit --kind next to the live calculation.
  • Nested calc walks — after calc-args finds a nested calc, read its name too.
  • Theme tooling — route different calculation kinds through different mixins.

🧠 How Compilation Works

1

Build a calculation

Write calc(), clamp(), min(), or max() in SCSS.

Source
2

Call calc-name

Dart Sass reads the calculation’s kind and returns a quoted string.

Compile
3

Compare or emit

Branch with @if, or interpolate the name into CSS variables.

Use
4

CSS ships

Browsers never see meta.calc-name—only finished CSS.

⚠️ Common Pitfalls

  • Passing a plain number10px is not a calculation; wrap or build calc/clamp/min/max first.
  • Comparing without quotes — prefer == "clamp" against the quoted return value.
  • Expecting CSS function text — you get the name only, not the full clamp(...) source.
  • Old Dart Sass — need 1.40+ for calculation introspection.
  • Skipping calc-args — name alone cannot recover argument values; call both when needed.

💡 Best Practices

✅ Do

  • Use @use "sass:meta" and meta.calc-name()
  • Compare with quoted strings like "clamp"
  • Pair with meta.calc-args for full inspection
  • Use names to validate design tokens before emit
  • Prefer Dart Sass 1.40+

❌ Don’t

  • Expect the browser to evaluate meta.calc-name
  • Pass non-calculation values
  • Assume the return includes parentheses or arguments
  • Forget to handle other kinds (min, max, …)
  • Rely on LibSass / Ruby Sass for this API

Key Takeaways

Knowledge Unlocked

Five things to remember about meta.calc-name()

Quoted calculation name—"calc", "clamp", and friends.

5
Core concepts
📦 02

Module

sass:meta

@use
📄 03

Returns

quoted string

Rule
04

Pair with

meta.calc-args

Safe
05

Prefer

Dart Sass 1.40+

Tooling

❓ 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.
Did you know?

Official Sass docs use the same two expressions for both meta.calc-name and meta.calc-argscalc(100px + 10%) and clamp(50px, var(--width), 1000px)—so you can learn the name/args pair on one familiar pair of samples.

Conclusion

meta.calc-name() returns a quoted string naming a CSS calculation—perfect for @if branches and token tooling. Pair it with meta.calc-args when you also need the contents, and use Dart Sass 1.40+ with @use "sass:meta".

Continue with meta.call() or the Sass introduction.

Next: call a function value

Learn meta.call() to invoke function values dynamically.

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.

5 people found this page helpful