Sass meta.get-function() Function

Intermediate
⏱️ 12 min read
📚 Updated: Jul 2026
🎯 5 Examples
sass:meta · + meta.call

What You’ll Learn

meta.get-function() belongs to the built-in sass:meta module. It turns a function name into a function value you can store, pass around, and run with meta.call. This page covers $module, $css, vs function-exists, and five compiled examples.

01

Concept

Name → function value

02

Module

@use "sass:meta"

03

Returns

Function value

04

Invoke

meta.call($fn, …)

05

Options

$module / $css

06

Practice

5 examples

What Is meta.get-function()?

Normally you write double(21) with a fixed name. Higher-order helpers need a reference to a function instead. Official docs: meta.get-function returns the function value named $name, and you invoke it with meta.call().

  • Without $module, looks up a function without a namespace (including many globals).
  • With $module, looks inside a @use namespace from the current file.
  • Default: missing Sass names throw. With $css: true, you get a plain CSS function instead.
💡
Beginner tip

get-function picks a tool from the toolbox. meta.call uses it. For mixins, the cousins are meta.get-mixin and meta.apply.

📝 Syntax

styles.scss
@use "sass:meta";

// Recommended
meta.get-function($name, $css: false, $module: null)

// Legacy global name
get-function($name, $css: false, $module: null)

Parameters

ParameterTypeRequiredDescription
$nameStringYesFunction name to resolve (without parentheses).
$cssBooleanNoDefault false: missing Sass functions error. true: return a plain CSS function value instead.
$moduleString or nullNoIf set, must match a @use namespace in the current file.

Return value

TypeResult
FunctionA Sass function value (or a plain CSS function when $css: true)

📦 Loading sass:meta

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

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

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

🔗 Pair with meta.call

Official rule: the returned function is called using meta.call(). Prefer this over the deprecated string form of call("name", …).

styles.scss
@use "sass:meta";

@function triple($n) {
  @return $n * 3;
}

$fn: meta.get-function("triple");
$result: meta.call($fn, 14); // 42

⚙ The $css Flag

By default, an unknown Sass function name throws. Set $css: true when you want a plain CSS function value instead (for example to keep min / clamp as CSS at the call site).

$cssMissing Sass name
false (default)Compile error
trueReturns a plain CSS function value

📋 Related Meta Helpers

HelperRole
meta.function-existsBoolean: is the function defined?
meta.get-functionFunction value: resolve the reference
meta.callInvoke a function value with arguments
meta.get-mixin + meta.applySame idea for mixins / CSS emission

🛠 Compatibility

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

Implementationget-function
Dart SassYes — prefer meta.get-function with modules
LibSass (3.5+)Yes (function values; legacy pipelines)
Ruby Sass (3.5+)Yes (function values; legacy pipelines)

Prefer current Dart Sass for @use and $module.

⚡ Quick Reference

GoalCode
Import meta@use "sass:meta";
Local functionmeta.get-function("double")
Module functionmeta.get-function("pow", $module: "math")
Invoke itmeta.call($fn, $arg1, $arg2)
Plain CSS fallbackmeta.get-function("min", $css: true)
Safe optional path@if meta.function-exists(…) { get-function … }

Examples Gallery

Each example resolves a function value, then uses it (usually via meta.call). Open View Compiled CSS for verified Dart Sass output.

📚 Getting Started

Simple resolve + call, and the official higher-order filter.

Example 1 — Basic get-function + call

Resolve a local function, store it, then invoke it.

styles.scss
@use "sass:meta";

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

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

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

How It Works

$fn holds a function value, not a string. meta.call($fn, 55px) is equivalent to double(55px).

Example 2 — Pass a Function into a Helper (Official Docs)

Hand meta.get-function("contains-helvetica") to 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

remove-where never hard-codes the condition function. It receives a function value from get-function and runs it with meta.call on each item.

📈 Practical Patterns

Module functions, choosing a helper, and the $css flag.

Example 3 — Resolve a Module Function

Use $module: "math" for sass:math members.

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

The namespace string must match @use "sass:math". If you alias as as m, pass $module: "m".

Example 4 — Choose a Function Dynamically

Pick one of two local helpers, then call the chosen value.

styles.scss
@use "sass:meta";

@function grow($n) {
  @return $n * 1.5;
}

@function shrink($n) {
  @return $n * 0.75;
}

$mode: "grow";
$fn: if(
  $mode == "grow",
  meta.get-function("grow"),
  meta.get-function("shrink")
);

.panel {
  padding: meta.call($fn, 16px);
}

How It Works

One meta.call site serves either adjuster. Flip $mode without rewriting the property line.

Example 5 — Plain CSS Function with $css: true

Resolve min as a CSS function and emit it through meta.call.

styles.scss
@use "sass:meta";

$min: meta.get-function("min", $css: true);

.box {
  width: meta.call($min, 50vw, 640px);
}

How It Works

Without $css: true, an unknown Sass min name would error (or collide with older global behavior). With the flag, Sass keeps a CSS min(…) in the output.

🚀 Real-World Use Cases

  • Higher-order helpers — filters, mappers, and reducers that accept a function value.
  • Configurable adjusters — choose grow/shrink (or theme helpers) from a flag.
  • Module bridging — resolve sass:math / other built-ins via $module.
  • Safe dynamic APIs — pair with meta.function-exists before resolving.
  • CSS function references$css: true when you need plain CSS callables.

🧠 How Compilation Works

1

Resolve by name

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

Source
2

Hold a function value

Store it in a variable or pass it into another function.

Value
3

Invoke with meta.call

Forward arguments and receive the return value.

Call
4

CSS ships

Browsers never see get-function—only finished CSS.

⚠️ Common Pitfalls

  • Forgetting $modulemath.pow will not resolve from a bare "pow".
  • Missing name without $css — throws at compile time.
  • Stopping at get-function — you still need meta.call to run it.
  • String call("name") — deprecated; resolve with get-function first.
  • Wrong namespace alias$module must match this file’s @use … as name.

💡 Best Practices

✅ Do

  • Use @use "sass:meta" and meta.get-function()
  • Invoke results with meta.call
  • Pass $module for namespaced built-ins
  • Guard optional names with meta.function-exists
  • Prefer Dart Sass for modules

❌ Don’t

  • Pass string names to call() in new code
  • Assume bare names find sass:math members
  • Confuse this with meta.get-mixin
  • Expect the browser to resolve function values
  • Skip $css: true when you need a plain CSS callable

Key Takeaways

Knowledge Unlocked

Five things to remember about meta.get-function()

Resolve a function value by name, then run it with meta.call.

5
Core concepts
📦 02

Module

sass:meta

@use
🔗 03

Returns

function value

Result
04

Options

$module / $css

Flags
05

Invoke

meta.call($fn, …)

Next

❓ Frequently Asked Questions

meta.get-function($name, $css: false, $module: null) returns a function value for the named function. You typically run that value with meta.call($fn, $args...).
When the function lives under a @use namespace. For example meta.get-function("pow", $module: "math") after @use "sass:math". The string must match that file’s namespace.
By default, a missing Sass function name throws. With $css: true, get-function returns a plain CSS function value instead—useful when you want to emit CSS like min() or clamp() as a function reference.
function-exists returns true/false. get-function returns the actual function value (or errors unless $css is true). Check with exists first for optional APIs.
Use meta.call($function, $args...). Passing a string name directly to call() is deprecated—get-function is the modern first step.
Yes. get-function($name, $css: false, $module: null) is the legacy global name. Prefer meta.get-function after @use "sass:meta".
Did you know?

Official Sass docs use the same remove-where sample for both meta.get-function and meta.call: resolve the condition once, pass the function value into the helper, and let meta.call run it on every list item.

Conclusion

meta.get-function() turns a function name into a reusable function value. Pass $module for @use namespaces, use $css: true for plain CSS callables, and always invoke the result with meta.call—the modern alternative to deprecated string call().

Continue with meta.get-mixin() or the Sass introduction.

Next: resolve a mixin value

Learn meta.get-mixin() to get a mixin reference for meta.apply.

meta.get-mixin() →

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