meta.apply() belongs to the built-in sass:meta module. It includes a mixin value with arguments you supply—like calling a mixin when you only have a reference to it. This page covers meta.get-mixin, @content forwarding, vs meta.call, Dart Sass 1.69+, and five compiled examples.
01
Concept
Dynamic mixin include
02
Module
@use "sass:meta"
03
How
@include meta.apply
04
Source
meta.get-mixin
05
vs call
Mixin vs function
06
Practice
5 examples
Concept
What Is meta.apply()?
Normally you write @include font-class(12px) with the mixin name fixed in the stylesheet. Sometimes you want to choose which mixin to run—pass it into another mixin, store it, or pick it from a map. Sass represents that choice as a mixin value. meta.apply includes that value with arguments.
You use it with @include (it is a meta mixin, not a returning function)
$mixin must be a mixin value—usually from meta.get-mixin("name")
Extra arguments after the mixin are forwarded as the mixin’s parameters
An optional @content block is forwarded into the applied mixin
💡
Beginner tip
Think of meta.get-mixin as picking a tool from a toolbox, and meta.apply as using that tool with the settings you pass. meta.call is the same idea for functions that return values.
Foundation
📝 Syntax
Load the meta module, then include the mixin:
styles.scss
@use "sass:meta";
@include meta.apply($mixin, $args...);
// With a content block (forwarded to $mixin)
@include meta.apply($mixin, $args...) {
// @content for the applied mixin
}
Parameters
Parameter
Type
Required
Description
$mixin
Mixin value
Yes
Mixin to include. Get one with meta.get-mixin($name) (or from meta.module-mixins).
$args...
Any (variadic)
No
Arguments passed through to the applied mixin’s parameters.
Return value
Type
Result
— (CSS output)
Emits whatever the applied mixin emits. Does not return a Sass value.
⚠️
Mixin, not a returning function
Despite the tutorial title pattern used across CodeToFun, meta.apply is documented as a mixin in sass:meta. Always @include it—do not assign it like $x: meta.apply(...).
Modules
📦 Loading sass:meta
There is no legacy global apply(). Load the meta module and include meta.apply.
styles.scss
// Recommended — namespaced
@use "sass:meta";
@include meta.apply(meta.get-mixin("font-class"), 12px);
// Optional — bring members into scope
@use "sass:meta" as *;
@include apply(get-mixin("font-class"), 12px);
// Optional — custom namespace
@use "sass:meta" as m;
@include m.apply(m.get-mixin("font-class"), 12px);
⚠️
Put @use first
Keep @use "sass:meta"; near the top of the file, before most other rules.
Details
🔗 Pair with meta.get-mixin
meta.apply does not accept a string mixin name by itself. First resolve the mixin value:
meta.apply($mixin, $args...) includes a mixin value with the given arguments. Use it with @include. It is the mixin counterpart to meta.call(), which runs function values.
Usually with meta.get-mixin("name") for a mixin in the current module, or from meta.module-mixins($namespace). You cannot pass a plain string to meta.apply—pass a mixin value.
Yes. If you pass a @content block to @include meta.apply(...), that content is forwarded into the applied mixin.
It is a mixin from sass:meta. You include it with @include meta.apply(...). It emits CSS through the mixin it runs; it does not return a value like map.get.
meta.apply runs mixins (CSS / @content). meta.call runs functions (returns a value). Same idea—dynamic invocation—different Sass member types.
Dart Sass 1.69+. LibSass and Ruby Sass do not provide this meta mixin API. Prefer current Dart Sass.
Did you know?
Official Sass docs introduce meta.apply and meta.get-mixin together (Dart Sass 1.69). The same apply-to-all sample appears in both topics so you can see the resolve-then-include workflow in one place.
meta.apply() lets you include a mixin value with arguments—and optional @content—when the mixin is chosen dynamically. Resolve values with meta.get-mixin, always @include the apply mixin, and use Dart Sass 1.69+. Reach for meta.call when you need functions that return values instead.