Sass meta.call()

Intermediate
9 min read
Updated: Nov 2026
5 examples
Dart Sass

Definition and Usage

meta.call($function, $args...) invokes a function value with the given arguments and returns the result. Get the function value from meta.get-function() (or meta.module-functions()). Load it with @use "sass:meta".

Official sample idea.

A remove-where($list, $condition) helper calls meta.call($condition, $element) for each item—for example filtering font names that contain “Helvetica”.

String names are deprecated.

Passing a string function name to call() still works, but Sass deprecates it and will disallow it later. Prefer meta.get-function then meta.call.

Returns a value.

Unlike meta.apply (mixins / CSS), meta.call is an expression that yields a result you can assign or emit.

Syntax

SCSS
@use "sass:meta";

meta.call($function, $args...); //=> value

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

meta.call(meta.get-function("double"), 8px); // 16px

// Deprecated: meta.call("double", 8px);
// Prefer get-function first

// Global alias (legacy): call($function, $args...)
// Prefer meta.call after @use "sass:meta"

Pattern: resolve a function value → meta.call with args → use the returned value. For mixins, use meta.apply instead.

call vs apply

Same dynamic idea, different member types:

HelperRunsHow you use it
meta.callFunction valueExpression / assignment — returns a value
meta.applyMixin value@include meta.apply(...) — emits CSS / can take @content
meta.get-function—Builds the function value you call
String name to call—Deprecated; prefer get-function
Higher-order helpers.

Pass a function value into another function (like a condition callback), then invoke it with meta.call inside the loop.

SCSS Examples

Examples use @use "sass:meta". Open View Compiled CSS for verified output (matches official Sass docs samples where shown).

Example 1 — Call a Local Function Value

Resolve with get-function, then invoke with call.

SCSS
@use "sass:meta";

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

.basic {
  width: meta.call(meta.get-function("double"), 8px);
}

How It Works

  1. get-function returns a function value.
  2. meta.call runs it with 8px.
  3. Result is 16px.
  4. Same idea as double(8px), but dynamic.

Example 2 — Official Docs remove-where

Higher-order filter: call a condition function for each list item.

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

/// Return a copy of $list with all elements for which $condition returns `true`
/// removed.
@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

  1. Condition is a function value, not a hard-coded name.
  2. meta.call runs it per font string.
  3. Truthy hits (Helvetica names) are removed.
  4. Matches the official Sass docs CSS output.

Example 3 — Call a Built-in Function Value

get-function can resolve built-ins when no module is passed.

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

.builtin {
  --abs: #{meta.call(meta.get-function("abs", $module: "math"), -12px)};
}

How It Works

  1. $module: "math" targets the @use namespace.
  2. abs becomes a function value.
  3. meta.call returns 12px.
  4. Prefer math.abs(-12px) when the call is not dynamic.

Example 4 — Pass Multiple Arguments

Extra args after the function value fill the function signature.

SCSS
@use "sass:meta";

@function scale($n, $factor) {
  @return $n * $factor;
}

.multi {
  width: meta.call(meta.get-function("scale"), 10px, 3);
}

How It Works

  1. First argument is the function value.
  2. 10px and 3 fill $n and $factor.
  3. Result is 30px.
  4. Arity must still match the function.

Example 5 — Functions vs Mixins

Use call for return values; use apply for CSS-emitting mixins.

SCSS
@use "sass:meta";

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

@mixin card($pad) {
  .card {
    padding: $pad;
  }
}

.demo {
  margin: meta.call(meta.get-function("gap"), 4px);
  @include meta.apply(meta.get-mixin("card"), 1rem);
}

How It Works

  1. meta.call returns 8px for margin.
  2. meta.apply includes the mixin.
  3. Different APIs for functions vs mixins.
  4. Do not @include meta.call or assign meta.apply.

Edge Cases & Pitfalls

Most call bugs are string names, wrong member type, or mixing up apply.

type

Pass a function value

Use meta.get-function("name"). A bare string is deprecated and will break later.

vs

Mixins use meta.apply

meta.call cannot include a mixin. Use meta.apply with @include.

scope

Local functions need local scope

In the official sample, contains-helvetica is defined inside .content so get-function can see it there.

module

Namespaced built-ins

Pass $module to get-function when the name lives under a @use namespace like math.

Sass Support

Prefer the module form with current Dart Sass.

APIStatus
meta.call()Dart Sass via @use "sass:meta"
Global call()Legacy; prefer module form
String function nameDeprecated; will be removed
First argumentFunction value (e.g. from meta.get-function)

Compile with the Dart Sass CLI.

Key Takeaways

  • Invokes a function value and returns its result.
  • Pair with get-function; avoid deprecated string names.
  • Use for higher-order helpers; use apply for mixins.
  • Module form via @use "sass:meta".

One line: when a function value must be invoked dynamically, call meta.call($function, $args...).

Compile Notes

Practical checklist:

checklist.txt
1. @use "sass:meta"
2. Resolve a function value (get-function / module-functions)
3. meta.call($fn, $args...)
4. Do not pass a string name (deprecated)
5. Use meta.apply for mixin values

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.

Next: Sass meta.content-exists()

Detect whether the current mixin received a @content block.

meta.content-exists() →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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