In Sass a function is a value. Look one up with meta.get-function(), keep it in a variable, pass it to other functions, store it in a map—then run it later with meta.call().
This gives you higher-order functions: a helper that accepts another function as an argument, such as one that applies a transform to every item in a list.
Not CSS.
A function value only exists at compile time. You cannot write it into a property; meta.inspect() prints it as get-function("double") and meta.type-of() reports function.
Look up, then call.
meta.get-function("name") returns the value. meta.call($fn, $args...) invokes it, passing positional or keyword arguments just like a normal call.
Names are strings.
meta.get-function("double") takes the name of an existing function. A name that does not exist is a compile error, so check with meta.function-exists() when unsure.
Syntax
Syntax
SCSS
@use "sass:meta";
@function double($n) {
@return $n * 2;
}
$fn: meta.get-function("double");
meta.call($fn, 4px); // 8px
meta.get-function("abs", $module: "math"); // function from a @use'd module
meta.get-function("translate", $css: true); // plain CSS function
// meta.get-function($name, $css: false, $module: null)
Pattern: define a function → meta.get-function returns a value → pass or store it → meta.call runs it when needed.
Functions are values you can store and pass around.
meta.get-function looks one up; meta.call runs it.
Helpers can accept functions, giving you higher-order tools.
Function values never reach CSS—only their results do.
One line: look up a function with meta.get-function(), then run it later with meta.call().
Practice
Compile Notes
Practical checklist:
checklist.txt
1. Define the function with @function
2. $fn: meta.get-function("name")
3. Pass $fn to helpers or store it in a map
4. meta.call($fn, args...) to run it
5. Use meta.function-exists() for dynamic names
Frequently Asked Questions
A function value is a first-class value that refers to a function. You get one with meta.get-function() and run it with meta.call().
Use meta.call($fn, $args...). For example, meta.call($fn, 4px) runs the function and returns its result.
Yes. Pass the value from meta.get-function() to a helper function or mixin, then call it with meta.call() inside.
Use meta.get-function("abs", $module: "math") where the module name matches the @use namespace. Use $css: true for a plain CSS function.
No. A function value is not valid CSS. Use meta.inspect() to see it as get-function("name") while debugging.
meta.get-function() throws a compile error. Check with meta.function-exists() first when the name is not fixed.