Sass meta.call() Function

Intermediate
⏱️ 12 min read
📚 Updated: Jul 2026
🎯 5 Examples
String args deprecated
sass:meta · Dart Sass

What You’ll Learn

meta.call() belongs to the built-in sass:meta module. It invokes a function value with arguments and returns the result. This page covers meta.get-function, higher-order helpers, the deprecated string form, vs meta.apply, and five compiled examples.

01

Concept

Call a function value

02

Module

@use "sass:meta"

03

Source

meta.get-function

04

Returns

Function result

05

vs apply

Functions vs mixins

06

Practice

5 examples

What Is meta.call()?

Normally you write math.pow(2, 8) with the function name fixed. Sometimes you want to pass a function into another function—a filter, a mapper, a condition. Sass represents that as a function value. meta.call runs it.

  • $function must be a function value (usually from meta.get-function)
  • Extra arguments are forwarded to that function
  • The return value is whatever the invoked function returns
💡
Beginner tip

Think of meta.get-function as picking a tool from a toolbox, and meta.call as using that tool. For mixins that emit CSS, use meta.apply instead.

📝 Syntax

styles.scss
@use "sass:meta";

// Recommended
meta.call($function, $args...)

// Legacy global name (same idea)
call($function, $args...)

Parameters

ParameterTypeRequiredDescription
$functionFunction valueYesFunction to invoke. Get one with meta.get-function($name). Avoid passing a string name (deprecated).
$args...Any (variadic)NoArguments forwarded to the function value.

Return value

TypeResult
AnyWhatever the invoked function returns (number, color, list, boolean, …)

📦 Loading sass:meta

styles.scss
// Recommended — namespaced
@use "sass:meta";
@use "sass:math";
$result: meta.call(meta.get-function("abs", $module: "math"), -4);

// Optional — bring members into scope
@use "sass:meta" as *;
$result: call(get-function("abs", $module: "math"), -4);

// Legacy global
$result: call(get-function("abs", $module: "math"), -4);

🔗 Pair with meta.get-function

Official rule: $function must be a function value. Resolve it first:

styles.scss
@use "sass:meta";

@function double($n) {
  @return $n * 2;
}

$fn: meta.get-function("double");
$value: meta.call($fn, 21); // 42
  • meta.get-function($name) — current module
  • meta.get-function($name, $module: "ns") — from a @use namespace

⚠️ Deprecated: String Names

Older LibSass / Ruby Sass accepted call("function-name", …). That still works for compatibility, but Sass docs mark it deprecated because modules mean a name may not be globally unique.

Avoid (deprecated)Prefer
call("abs", -4)meta.call(meta.get-function("abs", $module: "math"), -4)

📋 meta.call vs meta.apply

meta.callmeta.apply
RunsFunction valuesMixin values
HowExpression: meta.call(...)@include meta.apply(...)
Gettermeta.get-functionmeta.get-mixin
OutputReturned Sass valueCSS / @content

🛠 Compatibility

This is about Sass compilers, not browsers. The call runs at compile time.

ImplementationFunction-value callString name (deprecated)
Dart SassYes — preferred with sass:metaWorks, but deprecated
LibSass (3.5+)Yes (legacy pipelines)Works, but deprecated
Ruby Sass (3.5+)Yes (legacy pipelines)Works, but deprecated

Prefer current Dart Sass and function values via meta.get-function.

⚡ Quick Reference

GoalCode
Import meta@use "sass:meta";
Get function valuemeta.get-function("name")
Invoke itmeta.call($fn, $arg1, $arg2)
From a modulemeta.get-function("pow", $module: "math")
Run a mixin instead@include meta.apply($mixin, …)
Avoidcall("name", …) string form

Examples Gallery

Each example uses function values (not deprecated strings). Open View Compiled CSS for verified Dart Sass output.

📚 Getting Started

Simple call and the official higher-order filter sample.

Example 1 — Basic get-function + call

Resolve a local function, then invoke it.

styles.scss
@use "sass:meta";

@function double($n) {
  @return $n * 2;
}

$fn: meta.get-function("double");

.box {
  width: meta.call($fn, 60px);
}

How It Works

meta.call($fn, 60px) is equivalent to double(60px), but $fn could be swapped for another function value.

Example 2 — Higher-Order Filter (Official Docs)

Pass a condition function into remove-where.

styles.scss
@use "sass:list";
@use "sass:meta";
@use "sass:string";

@function remove-where($list, $condition) {
  $new-list: ();
  $separator: list.separator($list);
  @each $element in $list {
    @if not meta.call($condition, $element) {
      $new-list: list.append($new-list, $element, $separator: $separator);
    }
  }
  @return $new-list;
}

$fonts: Tahoma, Geneva, "Helvetica Neue", Helvetica, Arial, sans-serif;

.content {
  @function contains-helvetica($string) {
    @return string.index($string, "Helvetica");
  }
  font-family: remove-where($fonts, meta.get-function("contains-helvetica"));
}

How It Works

For each font name, meta.call($condition, $element) runs contains-helvetica. Matching Helvetica entries are removed; the rest remain.

📈 Practical Patterns

Module functions, choosing a function, and mapping list items.

Example 3 — Call a Built-in Module Function

Resolve math.pow through get-function’s $module argument.

styles.scss
@use "sass:math";
@use "sass:meta";

$pow: meta.get-function("pow", $module: "math");

.scale {
  --eight: #{meta.call($pow, 2, 3)};
  width: meta.call($pow, 2, 4) * 1px;
}

How It Works

$module: "math" matches the @use "sass:math" namespace. meta.call($pow, 2, 3) returns 8.

Example 4 — Choose a Function Dynamically

Pick a darker or lighter adjuster from a config flag, then call the chosen value.

styles.scss
@use "sass:color";
@use "sass:meta";

@function make-darker($c, $amount) {
  @return color.adjust($c, $lightness: -$amount);
}

@function make-lighter($c, $amount) {
  @return color.adjust($c, $lightness: $amount);
}

$mode: "darken";
$adjust: if(
  $mode == "darken",
  meta.get-function("make-darker"),
  meta.get-function("make-lighter")
);

.btn {
  background: meta.call($adjust, #3b82f6, 15%);
}

How It Works

One meta.call site serves either adjuster. Change $mode to "lighten" without rewriting the property line. Local helpers wrap color.adjust so get-function can resolve them cleanly.

Example 5 — Map a List Through a Function

Apply the same function value to every spacing token.

styles.scss
@use "sass:list";
@use "sass:meta";

@function scale-space($n) {
  @return $n * 1.25;
}

@function map-call($list, $fn) {
  $out: ();
  @each $item in $list {
    $out: list.append($out, meta.call($fn, $item));
  }
  @return $out;
}

$spaces: 4px, 8px, 16px;
$scaled: map-call($spaces, meta.get-function("scale-space"));

.stack {
  gap: list.nth($scaled, 2);
}

How It Works

map-call never hard-codes scale-space. It receives any function value and builds a new list of results; the second scaled value is 10px.

🚀 Real-World Use Cases

  • Higher-order helpers — filters, mappers, and reducers over lists (official remove-where).
  • Theme adjusters — choose make-darker / make-lighter (or similar helpers) from config, then call once.
  • Module bridging — invoke sass:math / sass:color members via get-function + $module.
  • Plugin APIs — accept a function value from consumers instead of a fixed name.
  • Migration off string call() — replace deprecated call("name", …) safely.

🧠 How Compilation Works

1

Resolve a function value

Call meta.get-function("name") (optionally with $module).

Source
2

Invoke meta.call

Pass the function value and arguments.

Compile
3

Receive the result

Use the returned value in properties, lists, or further math.

Result
4

CSS ships

Browsers never see meta.call—only finished values.

⚠️ Common Pitfalls

  • String first argument — deprecated; resolve with meta.get-function first.
  • Confusing with meta.apply — functions return values; mixins emit CSS.
  • Wrong arity — argument count must match the target function.
  • Missing $module — built-ins from sass:math need the namespace when using get-function.
  • Expecting runtime JS callbacks — everything resolves when Sass compiles.

💡 Best Practices

✅ Do

  • Use @use "sass:meta" and meta.call()
  • Pass function values from meta.get-function
  • Build small higher-order helpers (filter / map)
  • Migrate old call("name", …) call sites
  • Prefer Dart Sass for modules

❌ Don’t

  • Pass a bare string as $function in new code
  • Use meta.call when you need a mixin (meta.apply)
  • Expect the browser to evaluate meta.call
  • Forget $module for namespaced built-ins
  • Rely on string call() for future-proof stylesheets

Key Takeaways

Knowledge Unlocked

Five things to remember about meta.call()

Invoke function values—never pass deprecated string names in new code.

5
Core concepts
📦 02

Module

sass:meta

@use
🔗 03

Input

function value

Rule
⚠️ 04

Strings

deprecated

Safe
05

vs apply

functions vs mixins

Tooling

❓ Frequently Asked Questions

meta.call($function, $args...) invokes a function value with the given arguments and returns the result. It is how you run a function when you hold a reference to it instead of writing its name directly.
Use meta.get-function("name") for a function in the current module, or pass $module for a @use namespace. You can also take function values from meta.module-functions.
It still works in current implementations, but Sass marks passing a string name as deprecated. Prefer meta.get-function() first, then meta.call($fn, …). String call() will be disallowed in future versions.
meta.call runs function values and returns a value. meta.apply includes mixin values and emits CSS (and can forward @content). Same dynamic idea, different member types.
Yes. call($function, $args...) is the legacy global name. Prefer meta.call after @use "sass:meta".
Dart Sass fully. LibSass and Ruby Sass support call with function values since about 3.5. Always prefer current Dart Sass for the module system.
Did you know?

Official Sass docs motivate function values (and deprecating string call()) for the module system: once functions live in namespaces, a bare name string may not refer to the same function everywhere—so you pass the resolved value instead.

Conclusion

meta.call() runs a function value with arguments and returns the result—the foundation for higher-order Sass helpers. Always resolve with meta.get-function, avoid deprecated string names, and use meta.apply when you need mixins instead of functions.

Continue with meta.content-exists() or the Sass introduction.

Next: detect @content

Learn meta.content-exists() to see if a mixin received a content block.

meta.content-exists() →

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