Sass meta.module-functions()

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

Definition and Usage

meta.module-functions($module) returns a map of every function defined in $module—keys are function names, values are function values. Dart Sass only. Load with @use "sass:meta".

Official sample idea.

After @use "functions", meta.call(map.get(meta.module-functions("functions"), "pow"), 3, 4) → 81.

$module matches a namespace.

Pass a string matching a @use namespace in the current file (e.g. "functions", "math"), or a module value.

Map values are not CSS.

Run them with meta.call. Peek at names with map.keys + meta.inspect.

Syntax

SCSS
@use "sass:map";
@use "sass:meta";
@use "functions";

meta.module-functions($module); //=> map

// Official pattern
meta.call(
  map.get(meta.module-functions("functions"), "pow"),
  3,
  4
); // 81

// Module API — Dart Sass only

Pattern: @use the module → module-functions for the catalog → map.get / map.has-key → meta.call.

Map Shape and Calling

What you get back and how to use it:

PieceMeaningTypical next step
Map keysFunction names as stringsmap.keys / map.has-key
Map valuesFunction valuesmeta.call($fn, $args...)
$module stringMust match this file’s @use namespace"functions", "math", …
vs function-existsOne name yes/noUse exists for a single check
vs get-functionOne function by nameUse module-functions for the full catalog
Sibling catalogs.

meta.module-mixins and meta.module-variables do the same for mixins and variables.

SCSS Examples

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

Example 1 — List Function Names in a Module

Inspect map.keys so you can see the catalog without printing function values.

SCSS
@function pow($base, $exponent) {
  $result: 1;
  @for $_ from 1 through $exponent {
    $result: $result * $base;
  }
  @return $result;
}

@function double($n) {
  @return $n * 2;
}
SCSS
@use "sass:map";
@use "sass:meta";
@use "functions";

$fns: meta.module-functions("functions");

.probe {
  --keys: #{meta.inspect(map.keys($fns))};
}

How It Works

  1. @use "functions" loads the partial.
  2. module-functions returns the map.
  3. map.keys lists the names.
  4. inspect peeks at them for learning / debug.

Example 2 — Official map.get + meta.call

Pick pow from the map and compute 34 = 81.

SCSS
@use "sass:map";
@use "sass:meta";
@use "functions";

.result {
  width: meta.call(
    map.get(meta.module-functions("functions"), "pow"),
    3,
    4
  ) * 1px;
}

How It Works

  1. map.get picks the pow function value.
  2. meta.call runs it with 3 and 4.
  3. Result is 81, then multiplied by 1px.
  4. Matches the official Sass docs sample.

Example 3 — Probe sass:math

After @use "sass:math", use map.has-key on the catalog.

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

$math-fns: meta.module-functions("math");

.probe {
  --has-div: #{map.has-key($math-fns, "div")};
  --has-pow: #{map.has-key($math-fns, "pow")};
  --has-nope: #{map.has-key($math-fns, "nope")};
}

How It Works

  1. Built-in modules work the same way.
  2. "math" must match this file’s @use namespace.
  3. div and pow are present.
  4. Unknown names return false from has-key.

Example 4 — Count Functions in a Module

Combine map.keys with list.length for a simple inventory.

SCSS
@use "sass:list";
@use "sass:map";
@use "sass:meta";
@use "functions";

$fns: meta.module-functions("functions");

.count {
  --n: #{list.length(map.keys($fns))};
}

How It Works

  1. _functions.scss exports pow and double.
  2. map.keys builds the name list.
  3. list.length counts them.
  4. Result is 2.

Example 5 — Guard Before meta.call

Check map.has-key so optional plugin names fail safely.

SCSS
@use "sass:map";
@use "sass:meta";
@use "functions";

$fns: meta.module-functions("functions");
$name: "double";

.box {
  @if map.has-key($fns, $name) {
    width: meta.call(map.get($fns, $name), 24px);
  } @else {
    width: 24px;
  }
}

How It Works

  1. has-key confirms double exists.
  2. meta.call runs double(24px).
  3. Result is 48px.
  4. Missing names take the @else fallback.

Edge Cases & Pitfalls

Most module-functions bugs are wrong namespace strings or forgetting meta.call.

namespace

String must match @use

After @use "sass:math" as m, pass "m", not "math".

call

Map values need meta.call

You cannot use a function value like a normal CSS value without calling it.

guard

Check before optional calls

Use map.has-key (or function-exists) before map.get + call.

dart

Dart Sass only

Official docs: LibSass / Ruby Sass do not provide this API.

Sass Support

Prefer the module form with current Dart Sass.

APIStatus
meta.module-functions()Dart Sass only via @use "sass:meta"
Return typeMap (name → function value)
$moduleNamespace string or module value
LibSass / Ruby SassNot available

Compile with the Dart Sass CLI.

Key Takeaways

  • Returns a map of every function in a loaded module.
  • Call with map.get + meta.call (official pattern).
  • $module matches @use namespace in the current file.
  • Dart Sass only — great for registries and dynamic helpers.

One line: to list every function in a @use module, use meta.module-functions($module).

Compile Notes

Practical checklist:

checklist.txt
1. @use "sass:meta" (+ "sass:map")
2. @use "your-module"
3. $fns: meta.module-functions("your-module")
4. map.get / map.has-key / map.keys
5. meta.call($fn, $args...) to run a value

Frequently Asked Questions

meta.module-functions($module) returns a map of every function defined in that @use module—keys are function names, values are function values you can run with meta.call.
A string matching the namespace of a @use rule in the current file—for example "functions" after @use "functions", or "math" after @use "sass:math". It can also be a module value.
Official pattern: meta.call(map.get(meta.module-functions("functions"), "pow"), 3, 4). map.get picks the function value; meta.call runs it.
function-exists answers yes/no for one name. module-functions returns the whole catalog of functions in a module as a map.
get-function looks up one function by name. module-functions returns all functions in a module at once—handy for registries, loops, and map.has-key guards.
Dart Sass only (docs note since the module system / 1.23+ era). LibSass and Ruby Sass do not. Prefer current Dart Sass.

Next: Sass meta.module-mixins()

Get a map of all mixins from a loaded module.

meta.module-mixins() →

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