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
Concept
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.
Foundation
📝 Syntax
Load the meta module, then call the function:
styles.scss
@use "sass:meta";
meta.calc-name($calc)
Parameters
Parameter
Type
Required
Description
$calc
Calculation
Yes
A CSS calculation value such as calc(...), clamp(...), min(...), or max(...).
Return value
Type
Result
Quoted string
The calculation’s name—for example "calc" or "clamp"
Modules
📦 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));
Details
🔢 Official Samples
From the Sass docs, the return values are quoted strings:
Each value keeps its CSS calculation in the property, while custom properties record the compile-time names min and max.
Applications
🚀 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.
Watch Out
⚠️ Common Pitfalls
Passing a plain number — 10px 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.
Pro Tips
💡 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
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about meta.calc-name()
Quoted calculation name—"calc", "clamp", and friends.
5
Core concepts
📝01
Call
meta.calc-name($calc)
API
📦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-args—calc(100px + 10%) and clamp(50px, var(--width), 1000px)—so you can learn the name/args pair on one familiar pair of samples.
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".