Sass meta.module-mixins() Function

Intermediate
⏱️ 12 min read
📚 Updated: Jul 2026
🎯 5 Examples
sass:meta · Dart Sass 1.69+

What You’ll Learn

meta.module-mixins() belongs to the built-in sass:meta module. It returns every mixin in a @used module as a map of names to mixin values. This page covers the official stretch + meta.apply pattern, safe map.has-key guards, and five compiled examples.

01

Concept

Module mixin catalog

02

Module

@use "sass:meta"

03

Returns

Map of mixin values

04

$module

Must match a @use name

05

Include path

map.get + meta.apply

06

Practice

5 examples

What Is meta.module-mixins()?

Official docs: returns all the mixins defined in a module, as a map from mixin names to mixin values. Think of it as opening a style toolkit and seeing every recipe labeled by name—ready to pick one with map.get and include it with meta.apply.

  • $module must be a string matching a @use namespace in the current file.
  • Map keys are mixin names (strings). Map values are mixin values (not CSS yet).
  • Pair with meta.apply to emit CSS (and forward @content).
  • Dart Sass 1.69+ only—LibSass and Ruby Sass do not support it.
💡
Beginner tip

meta.mixin-exists asks “is there one recipe named stretch?” meta.module-mixins hands you the whole cookbook from that module.

📝 Syntax

styles.scss
@use "sass:meta";

// Dart Sass 1.69+ (no legacy global name)
meta.module-mixins($module)

Parameters

ParameterTypeRequiredDescription
$moduleStringYesMust match the namespace of a @use rule in the current file.

Return value

TypeResult
MapMixin names → mixin values (use with meta.apply)

📦 Loading sass:meta

styles.scss
@use "sass:map";
@use "sass:meta";
@use "mixins";

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

.header {
  @include meta.apply(map.get($mx, "stretch"));
}

There is no legacy global module-mixins(). Always load sass:meta and call meta.module-mixins.

⚙ The Official Apply Pattern

Docs show listing a custom mixins module, then picking one mixin and including it:

styles.scss
@use "sass:map";
@use "sass:meta";
@use "mixins";

// Map of names → mixin values
@debug meta.module-mixins("mixins");
// ("stretch": get-mixin("stretch"), …)

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

If you wrote @use "mixins" as mx, pass "mx" as $module.

📋 Related Meta Helpers

HelperPurposeReturns
meta.module-mixinsAll mixins in a moduleMap of mixin values
meta.module-functionsAll functions in a moduleMap of function values
meta.module-variablesAll variables in a moduleMap of values
meta.get-mixinOne mixin by nameMixin value
meta.mixin-existsDoes one mixin exist?Boolean

🛠 Compatibility

This is about Sass compilers, not browsers. The map is built at compile time.

Implementationmodule-mixins
Dart SassYes — since 1.69.0
LibSassNo
Ruby SassNo

Prefer current Dart Sass. meta.apply / meta.get-mixin share the same 1.69+ requirement.

⚡ Quick Reference

GoalCode
Import meta (+ map)@use "sass:meta"; @use "sass:map";
List a module’s mixinsmeta.module-mixins("mixins")
See the namesmap.keys(meta.module-mixins("mixins"))
Include one by name@include meta.apply(map.get($mx, "stretch"))
Guard a name@if map.has-key($mx, $name) { … }
Single lookup insteadmeta.get-mixin("stretch", $module: "mixins")

Examples Gallery

Each example uses meta.module-mixins at compile time (Dart Sass 1.69+). Open View Compiled CSS for verified output.

📚 Getting Started

List a custom mixins module, then include one with meta.apply (official style).

Example 1 — List Mixin Names in a Module

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

styles.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);
}
styles.scss
@use "sass:map";
@use "sass:meta";
@use "mixins";

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

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

How It Works

module-mixins returns the map; map.keys + meta.inspect peeks at the names for debugging or docs.

Example 2 — Official map.get + meta.apply

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

styles.scss
@use "sass:map";
@use "sass:meta";
@use "mixins";

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

How It Works

Matches the official docs: map.get(…, "stretch") yields a mixin value; meta.apply includes it into the selector.

📈 Practical Patterns

Inventory probes, optional includes, and safe dynamic applies.

Example 3 — Count and Probe Keys

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

styles.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

Our sample _mixins.scss exports two mixins, so the count is 2. Missing names return false from has-key.

Example 4 — Optional Mixin Include

Include a helper only when the catalog contains it.

styles.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

Because soft-shadow is in the map, the card gets the shadow. Remove that mixin from the module and the card still compiles with padding only.

Example 5 — Guard Before meta.apply

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

styles.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

When $name is present, meta.apply includes it. If the name were missing, the @else branch would keep a safe fallback.

🚀 Real-World Use Cases

  • Theme / plugin registries — discover mixins a module exports, then include by name.
  • Layout toolkits — pick stretch, center, or similar helpers from a catalog.
  • Documentation / debug peeks — print map.keys while building a design system.
  • Safe optional APIsmap.has-key before meta.apply.
  • Module inventories — count or loop members for code generation at compile time.

🧠 How Compilation Works

1

@use a mixins module

Load mixins (or another namespace) in the current file.

Source
2

Build the mixin map

Call meta.module-mixins("mixins").

Compile
3

Pick and apply

Use map.get + @include meta.apply (or loop the keys).

Include
4

CSS ships

Browsers never see the map—only finished declarations.

⚠️ Common Pitfalls

  • Wrong namespace string — must match this file’s @use … as name exactly.
  • Module not loaded here — only @use rules in the current file count.
  • Confusing values with CSS — map values are mixin references until you meta.apply them.
  • Including without meta.apply — you cannot @include a map value directly; use meta.apply.
  • Older Dart Sass — needs 1.69+ (same family as get-mixin / apply).

💡 Best Practices

✅ Do

  • Use @use "sass:meta" and meta.module-mixins()
  • Store the map once in a variable when applying several times
  • Guard optional names with map.has-key
  • Prefer map.keys / meta.inspect for readable peeks
  • Run Dart Sass 1.69+

❌ Don’t

  • Pass a path string that is not a current-file @use namespace
  • Expect map values to emit CSS without meta.apply
  • Use it to list functions or variables (use the sibling helpers)
  • Assume browsers evaluate the lookup
  • Rely on LibSass / Ruby Sass

Key Takeaways

Knowledge Unlocked

Five things to remember about meta.module-mixins()

Get every mixin in a @use module as a map, then apply what you need.

5
Core concepts
📦 02

Module

sass:meta

@use
📚 03

Returns

map of mixins

Result
🔗 04

$module

@use namespace

Scope
05

Include

map.get + meta.apply

Tooling

❓ 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".
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+. LibSass and Ruby Sass do not. Prefer current Dart Sass.
Did you know?

Official Sass docs pair meta.module-mixins with map.get and meta.apply—the mixin twin of module-functions + meta.call, resolved entirely at compile time.

Conclusion

meta.module-mixins() returns a map of every mixin in a @used module. Match $module to that namespace, explore names with map.keys, and include helpers with map.get + meta.apply on Dart Sass 1.69+.

Continue with meta.module-variables() or the Sass introduction.

Next: list module variables

Learn meta.module-variables() to get every variable in a @use module as a map.

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.

5 people found this page helpful