Sass meta.module-mixins()

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

Definition and Usage

meta.module-mixins($module) returns a map of every mixin defined in $module—keys are mixin names, values are mixin values. Include them with meta.apply (Dart Sass 1.69+). Load with @use "sass:meta".

Official sample idea.

After @use "mixins", @include meta.apply(map.get(meta.module-mixins("mixins"), "stretch")) emits the stretch flex rules.

$module matches a namespace.

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

Map values are not CSS.

Include them with @include meta.apply($mixin). Peek at names with map.keys + meta.inspect.

Syntax

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

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

// Official pattern
.header {
  @include meta.apply(
    map.get(meta.module-mixins("mixins"), "stretch")
  );
}

// Module API — Dart Sass 1.69+ (with meta.apply)

Pattern: @use the module → module-mixins for the catalog → map.get / map.has-key → @include meta.apply.

Map Shape and Applying

What you get back and how to use it:

PieceMeaningTypical next step
Map keysMixin names as stringsmap.keys / map.has-key
Map valuesMixin values@include meta.apply($mixin)
$module stringMust match this file’s @use namespace"mixins", …
vs mixin-existsOne name yes/noUse exists for a single check
vs get-mixinOne mixin by nameUse module-mixins for the full catalog
Sibling catalogs.

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

SCSS Examples

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

Example 1 — List Mixin Names in a Module

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

SCSS
@mixin stretch() {
  align-items: stretch;
  display: flex;
  flex-direction: row;
}

@mixin soft-shadow {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
SCSS
@use "sass:map";
@use "sass:meta";
@use "mixins";

$mx: meta.module-mixins("mixins");

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

How It Works

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

Example 2 — Official map.get + meta.apply

Pick stretch from the map and include it on .header.

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

.header {
  @include meta.apply(
    map.get(meta.module-mixins("mixins"), "stretch")
  );
}

How It Works

  1. map.get picks the stretch mixin value.
  2. meta.apply includes it into the selector.
  3. CSS emits the flex stretch rules.
  4. Matches the official Sass docs CSS output.

Example 3 — Count and Probe Keys

Combine list.length with map.has-key for a quick inventory.

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

$mx: meta.module-mixins("mixins");

.count {
  --n: #{list.length(map.keys($mx))};
  --has-stretch: #{map.has-key($mx, "stretch")};
  --has-nope: #{map.has-key($mx, "nope")};
}

How It Works

  1. _mixins.scss exports two mixins.
  2. list.length counts the keys → 2.
  3. has-key finds stretch.
  4. Unknown names return false.

Example 4 — Optional Mixin Include

Include a helper only when the catalog contains it.

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

$mx: meta.module-mixins("mixins");

.card {
  @if map.has-key($mx, "soft-shadow") {
    @include meta.apply(map.get($mx, "soft-shadow"));
  }
  padding: 1rem;
}

How It Works

  1. has-key confirms soft-shadow.
  2. meta.apply includes it.
  3. padding always runs.
  4. Remove the mixin and the card still compiles with padding only.

Example 5 — Guard Before meta.apply

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

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

$mx: meta.module-mixins("mixins");
$name: "stretch";

.row {
  @if map.has-key($mx, $name) {
    @include meta.apply(map.get($mx, $name));
  } @else {
    display: block;
  }
}

How It Works

  1. $name is looked up in the catalog.
  2. True path applies the mixin value.
  3. Missing names take the @else fallback.
  4. Safer for plugin-style dynamic includes.

Edge Cases & Pitfalls

Most module-mixins bugs are wrong namespace strings or forgetting meta.apply.

namespace

String must match @use

After @use "mixins" as mx, pass "mx", not "mixins".

apply

Map values need meta.apply

You cannot @include a map entry directly—resolve with map.get, then apply.

guard

Check before optional applies

Use map.has-key (or mixin-exists) before map.get + apply.

vs

Functions use module-functions

Dynamic functions return values via module-functions + meta.call.

Sass Support

Prefer the module form with Dart Sass 1.69+ (for meta.apply).

APIStatus
meta.module-mixins()Dart Sass via @use "sass:meta"
Return typeMap (name → mixin value)
Include with@include meta.apply($mixin) (1.69+)
LibSass / Ruby SassNot available

Compile with the Dart Sass CLI.

Key Takeaways

  • Returns a map of every mixin in a loaded module.
  • Include with map.get + meta.apply (official pattern).
  • $module matches @use namespace in the current file.
  • Dart Sass 1.69+ for apply on mixin values.

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

Compile Notes

Practical checklist:

checklist.txt
1. @use "sass:meta" (+ "sass:map")
2. @use "your-module"
3. $mx: meta.module-mixins("your-module")
4. map.get / map.has-key / map.keys
5. @include meta.apply($mixin) to emit CSS

Frequently Asked Questions

meta.module-mixins($module) returns a map of every mixin defined in that @use module—keys are mixin names, values are mixin values you include with meta.apply.
A string matching the namespace of a @use rule in the current file—for example "mixins" after @use "mixins". It can also be a module value.
Official pattern: @include meta.apply(map.get(meta.module-mixins("mixins"), "stretch")). map.get picks the mixin value; meta.apply includes it.
mixin-exists answers yes/no for one name. module-mixins returns the whole catalog of mixins in a module as a map.
get-mixin looks up one mixin by name. module-mixins returns all mixins in a module at once—handy for registries, loops, and map.has-key guards.
Dart Sass 1.69+ (needed for meta.apply on mixin values). LibSass and Ruby Sass do not. Prefer current Dart Sass.

Next: Sass meta.module-variables()

Get a map of all variables from a loaded module.

meta.module-variables() →

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