Sass meta.get-mixin() Function

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

What You’ll Learn

meta.get-mixin() belongs to the built-in sass:meta module. It turns a mixin name into a mixin value you can store, pass around, and include with meta.apply. This page covers $module, @content, vs get-function, Dart Sass 1.69+, and five compiled examples.

01

Concept

Name → mixin value

02

Module

@use "sass:meta"

03

Returns

Mixin value

04

Include

@include meta.apply

05

Since

Dart Sass 1.69+

06

Practice

5 examples

What Is meta.get-mixin()?

Normally you write @include card; with a fixed name. Higher-order helpers need a reference to a mixin instead. Official docs: meta.get-mixin returns the mixin value named $name, and you include it with meta.apply().

  • Without $module, looks up a mixin defined in the current module.
  • With $module, looks inside a @use namespace from the current file.
  • Missing names throw by default—use meta.mixin-exists for optional APIs.
💡
Beginner tip

get-mixin picks a tool from the toolbox. meta.apply uses it (and can forward @content). For functions, the cousins are meta.get-function and meta.call.

📝 Syntax

styles.scss
@use "sass:meta";

// Recommended — Dart Sass 1.69+
meta.get-mixin($name, $module: null)

Parameters

ParameterTypeRequiredDescription
$nameStringYesMixin name to resolve (without parentheses).
$moduleString or nullNoIf set, must match a @use namespace in the current file.

Return value

TypeResult
Mixin valueA mixin you include with @include meta.apply($mixin, …)

Unlike meta.get-function, there is no $css flag—mixin names must resolve to real Sass mixins.

📦 Loading sass:meta

styles.scss
// Recommended — namespaced
@use "sass:meta";

@mixin stamp {
  color: teal;
}

$m: meta.get-mixin("stamp");
.box {
  @include meta.apply($m);
}

// Optional — bring members into scope
@use "sass:meta" as *;
$m: get-mixin("stamp");
@include apply($m);

// Alias
@use "sass:meta" as m;
$m: m.get-mixin("stamp");
@include m.apply($m);

🔗 Pair with meta.apply

Official rule: the returned mixin is included using meta.apply(). Remember apply is a mixin—always use @include.

styles.scss
@use "sass:meta";

@mixin pad($n) {
  padding: $n;
}

$mx: meta.get-mixin("pad");

.card {
  @include meta.apply($mx, 1rem);
}

// Optional @content is forwarded into the applied mixin
@include meta.apply($mx, 0.5rem) {
  // only useful if the target mixin uses @content
}

📋 Related Meta Helpers

HelperRole
meta.mixin-existsBoolean: is the mixin defined?
meta.get-mixinMixin value: resolve the reference
meta.applyInclude a mixin value (CSS / @content)
meta.accepts-contentCan this mixin value take @content?
meta.get-function + meta.callSame idea for functions / returned values

🛠 Compatibility

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

Implementationmeta.get-mixin()Notes
Dart Sass (1.69+)Yes — requiredMixin values + meta.apply landed in 1.69.0
LibSassNoNo modern mixin-value API
Ruby SassNoLegacy—prefer Dart Sass

Prefer current Dart Sass 1.69+ for get-mixin and apply.

⚡ Quick Reference

GoalCode
Import meta@use "sass:meta";
Local mixinmeta.get-mixin("card")
Module mixinmeta.get-mixin("name", $module: "ns")
Include it@include meta.apply($mx, $arg)
Forward content@include meta.apply($mx) { … }
Safe optional path@if meta.mixin-exists(…) { get-mixin … }

Examples Gallery

Each example resolves a mixin value, then includes it with meta.apply. Open View Compiled CSS for verified Dart Sass output (1.69+).

📚 Getting Started

Simple resolve + apply, and the official apply-to-all pattern.

Example 1 — Basic get-mixin + apply

Resolve a local mixin, store it, then include it.

styles.scss
@use "sass:meta";

@mixin stamp {
  color: teal;
  font-weight: 700;
}

$mx: meta.get-mixin("stamp");

.box {
  @include meta.apply($mx);
}

How It Works

$mx holds a mixin value, not a string. @include meta.apply($mx) is equivalent to @include stamp.

Example 2 — Apply One Mixin to Many Values (Official Docs)

Pass meta.get-mixin("font-class") into a higher-order helper.

styles.scss
@use "sass:meta";

@mixin apply-to-all($mixin, $list) {
  @each $element in $list {
    @include meta.apply($mixin, $element);
  }
}

@mixin font-class($size) {
  .font-#{$size} {
    font-size: $size;
  }
}

$sizes: 8px, 12px, 2rem;

@include apply-to-all(meta.get-mixin("font-class"), $sizes);

How It Works

apply-to-all never hard-codes font-class. It receives a mixin value from get-mixin and includes it once per list item.

📈 Practical Patterns

Choosing a mixin, forwarding @content, and safe guards.

Example 3 — Choose a Mixin Dynamically

Pick one of two local mixins, then apply the chosen value.

styles.scss
@use "sass:meta";

@mixin solid {
  border: 2px solid #334155;
}

@mixin dashed {
  border: 2px dashed #94a3b8;
}

$style: "solid";
$mx: if(
  $style == "solid",
  meta.get-mixin("solid"),
  meta.get-mixin("dashed")
);

.panel {
  @include meta.apply($mx);
}

How It Works

One meta.apply site serves either border style. Flip $style without rewriting the include line.

Example 4 — Forward @content Through apply

Resolve a wrapper mixin, then pass a content block into meta.apply.

styles.scss
@use "sass:meta";

@mixin frame {
  border: 1px solid #cbd5e1;
  padding: 1rem;
  @content;
}

$mx: meta.get-mixin("frame");

.card {
  @include meta.apply($mx) {
    color: #0f172a;
  }
}

How It Works

get-mixin only resolves the mixin. @include meta.apply($mx) { … } forwards the content block into frame’s @content.

Example 5 — Guard with mixin-exists + accepts-content

Only resolve and apply when the mixin exists and can take content.

styles.scss
@use "sass:meta";

@mixin shell {
  display: block;
  @content;
}

$name: "shell";

.widget {
  @if meta.mixin-exists($name) {
    $mx: meta.get-mixin($name);
    @if meta.accepts-content($mx) {
      @include meta.apply($mx) {
        margin: 1rem;
      }
    } @else {
      @include meta.apply($mx);
    }
  }
}

How It Works

mixin-exists avoids a missing-name error. accepts-content decides whether forwarding a content block is safe.

🚀 Real-World Use Cases

  • Higher-order mixins — apply one mixin across a list of tokens (official apply-to-all).
  • Theme switches — choose solid/dashed (or brand variants) from config.
  • Plugin APIs — accept a mixin value from consumers instead of a fixed name.
  • Content-aware wrappers — resolve, check accepts-content, then forward blocks.
  • Module bridging — pull mixins from another @use namespace via $module.

🧠 How Compilation Works

1

Resolve by name

Call meta.get-mixin("name") (optionally with $module).

Source
2

Hold a mixin value

Store it or pass it into another mixin / helper.

Value
3

Include with meta.apply

Forward arguments and optional @content.

Apply
4

CSS ships

Browsers never see get-mixin—only finished CSS.

⚠️ Common Pitfalls

  • Treating apply like a function — always @include meta.apply(…).
  • Missing name — throws; guard with meta.mixin-exists.
  • Wrong $module — must match this file’s @use … as name.
  • Confusing with get-function — mixins emit CSS; functions return values.
  • Old Dart Sass — needs 1.69+ for mixin values.

💡 Best Practices

✅ Do

  • Use @use "sass:meta" and meta.get-mixin()
  • Include results with @include meta.apply
  • Pass $module for namespaced mixins
  • Guard optional names with mixin-exists
  • Target Dart Sass 1.69+

❌ Don’t

  • Pass a plain string to meta.apply
  • Assign meta.apply(…) like a returned value
  • Expect LibSass / Ruby Sass support
  • Forward @content without checking accepts-content in shared APIs
  • Expect the browser to resolve mixin values

Key Takeaways

Knowledge Unlocked

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

Resolve a mixin value by name, then include it with meta.apply.

5
Core concepts
📦 02

Module

sass:meta

@use
🔗 03

Returns

mixin value

Result
04

Include

meta.apply

Next
05

Since

Dart Sass 1.69+

Req

❓ Frequently Asked Questions

meta.get-mixin($name, $module: null) returns a mixin value for the named mixin. You include that value with @include meta.apply($mixin, $args...).
When the mixin lives under a @use namespace. $module must match that namespace string in the current file.
get-mixin resolves mixins (for meta.apply / CSS). get-function resolves functions (for meta.call / returned values).
Official docs: by default get-mixin throws if $name does not refer to a mixin. Guard optional names with meta.mixin-exists first.
get-mixin only resolves the mixin. When you @include meta.apply($mixin) { … }, that content block is forwarded into the applied mixin.
Dart Sass 1.69+. LibSass and Ruby Sass do not provide this API. Prefer current Dart Sass.
Did you know?

Official Sass docs use the same apply-to-all + font-class sample for both meta.get-mixin and meta.apply: resolve the mixin once, pass the mixin value into the helper, and let meta.apply include it for every list item.

Conclusion

meta.get-mixin() turns a mixin name into a reusable mixin value. Pass $module for @use namespaces, include the result with @include meta.apply, and use mixin-exists / accepts-content for safer shared APIs on Dart Sass 1.69+.

Continue with meta.global-variable-exists() or the Sass introduction.

Next: check global variables

Learn meta.global-variable-exists() to detect root-level tokens.

meta.global-variable-exists() →

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