Sass meta.accepts-content() Function

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

What You’ll Learn

meta.accepts-content() belongs to the built-in sass:meta module. It returns whether a mixin value can accept a @content block. This page covers pairing it with meta.get-mixin and meta.apply, what “possible” means, Dart Sass 1.69+, and five compiled examples.

01

Concept

Can mixin take content?

02

Module

@use "sass:meta"

03

Input

Mixin value

04

Result

true / false

05

With apply

Safe content forward

06

Practice

5 examples

What Is meta.accepts-content()?

Some mixins are written to receive nested CSS through a @content block:

styles.scss
@mixin card {
  .card {
    @content;
  }
}

@include card {
  padding: 1rem;
}

Other mixins never declare @content. When you work with mixin values (from meta.get-mixin) and include them via meta.apply, you may not know ahead of time whether forwarding a content block is allowed. meta.accepts-content($mixin) answers that with a boolean.

  • Returns true if the mixin can accept @content
  • Official docs: true even if the mixin does not always use the block
  • Returns false for mixins that cannot take content
💡
Beginner tip

Think of asking “Does this tool have a slot for extra pieces?” before you try to attach a content block with meta.apply.

📝 Syntax

Load the meta module, then call the function:

styles.scss
@use "sass:meta";

meta.accepts-content($mixin)

Parameters

ParameterTypeRequiredDescription
$mixinMixin valueYesMixin to inspect. Usually from meta.get-mixin($name) (or meta.module-mixins).

Return value

TypeSituationResult
BooleanMixin can accept @contenttrue (even if content is not always used)
BooleanMixin cannot accept @contentfalse

📦 Loading sass:meta

There is no legacy global accepts-content(). Load the meta module, then call the namespaced function.

styles.scss
// Recommended — namespaced
@use "sass:meta";
$ok: meta.accepts-content(meta.get-mixin("card"));

// Optional — bring members into scope
@use "sass:meta" as *;
$ok: accepts-content(get-mixin("card"));

// Optional — custom namespace
@use "sass:meta" as m;
$ok: m.accepts-content(m.get-mixin("card"));
⚠️
Put @use first

Keep @use "sass:meta"; near the top of the file, before most other rules.

🔗 Pair with get-mixin and apply

These three helpers work as a set (all Dart Sass 1.69+ for mixin values):

HelperRole
meta.get-mixin($name)Resolve a mixin value by name
meta.accepts-content($mixin)Ask if that value can take @content
@include meta.apply($mixin, …)Include the mixin (optionally with a content block)
styles.scss
@use "sass:meta";

$m: meta.get-mixin("panel");

@if meta.accepts-content($m) {
  @include meta.apply($m, 8px) {
    padding: 1rem;
  }
} @else {
  @include meta.apply($m, 8px);
}

📋 “Can Accept” vs “Always Uses”

Official wording matters: the function returns true if it is possible for the mixin to accept a content block, even if it does not always do so. Treat true as “safe to pass content,” not “content is required.”

  • true — you may forward @content via meta.apply
  • false — do not pass a content block; include the mixin without one

🛠 Compatibility

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

Implementationmeta.accepts-content()Notes
Dart Sass (1.69+)Yes — requiredShips with mixin values / meta.apply
LibSassNoNo modern mixin-value API
Ruby SassNoLegacy—prefer Dart Sass

⚡ Quick Reference

GoalCode
Import meta@use "sass:meta";
Get mixin valuemeta.get-mixin("name")
Check content supportmeta.accepts-content($m)
Include with content@include meta.apply($m) { ... }
Include without content@include meta.apply($m, $args...);
Minimum Dart Sass1.69+

Examples Gallery

Each example uses @use "sass:meta". Open View Compiled CSS to see what Dart Sass emits (booleans shown via custom properties where helpful).

📚 Getting Started

True and false results from real mixin values.

Example 1 — Mixin That Accepts @content

A wrapper mixin with @content returns true.

styles.scss
@use "sass:meta";

@mixin panel {
  .panel {
    @content;
  }
}

$m: meta.get-mixin("panel");

.check {
  --accepts: #{meta.accepts-content($m)};
}

@include meta.apply($m) {
  padding: 1rem;
}

How It Works

Because panel declares @content, meta.accepts-content is true, and meta.apply can safely forward the block.

Example 2 — Mixin Without @content

A plain mixin returns false.

styles.scss
@use "sass:meta";

@mixin solid-btn {
  .btn {
    background: #1d4ed8;
    color: #fff;
  }
}

$m: meta.get-mixin("solid-btn");

.check {
  --accepts: #{meta.accepts-content($m)};
}

@include meta.apply($m);

How It Works

No @content in solid-btn, so the check is false. Include it with meta.apply and no content block.

📈 Practical Patterns

Guards, reusable helpers, and compile-time debugging.

Example 3 — Guard Before Forwarding Content

Branch so content is only passed when the mixin allows it.

styles.scss
@use "sass:meta";

@mixin box($radius) {
  .box {
    border-radius: $radius;
    @content;
  }
}

$m: meta.get-mixin("box");

@if meta.accepts-content($m) {
  @include meta.apply($m, 8px) {
    padding: 1rem;
    background: #f8fafc;
  }
} @else {
  @include meta.apply($m, 8px);
}

How It Works

The @if chooses the content-aware include path. Swap in a mixin without @content and the @else branch would run instead.

Example 4 — Higher-Order Helper

Wrap meta.apply so callers can optionally supply content safely.

styles.scss
@use "sass:meta";

@mixin stack {
  .stack > * + * {
    margin-top: 0.75rem;
  }
}

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

@mixin include-maybe($name) {
  $m: meta.get-mixin($name);
  @if meta.accepts-content($m) {
    @include meta.apply($m) {
      @content;
    }
  } @else {
    @include meta.apply($m);
  }
}

@include include-maybe("stack");

@include include-maybe("frame") {
  padding: 1rem;
}

How It Works

include-maybe inspects each mixin value. Content from the caller reaches frame, while stack is included without a content block.

Example 5 — Compare Two Mixins with @debug

Quick compile-time inspection while learning.

styles.scss
@use "sass:meta";

@mixin with-slot {
  .slot { @content; }
}

@mixin no-slot {
  .plain { color: #334155; }
}

@debug meta.accepts-content(meta.get-mixin("with-slot")); // true
@debug meta.accepts-content(meta.get-mixin("no-slot"));   // false

.flags {
  --with-slot: #{meta.accepts-content(meta.get-mixin("with-slot"))};
  --no-slot: #{meta.accepts-content(meta.get-mixin("no-slot"))};
}

How It Works

@debug prints to the Sass compiler console; the custom properties mirror the same booleans in CSS for easy verification.

🚀 Real-World Use Cases

  • Safe meta.apply wrappers — forward @content only when allowed.
  • Plugin / library APIs — accept a mixin name or value from users and adapt.
  • Design-system generators — one helper for both slot and non-slot mixins.
  • Compile-time validation — fail early or branch when content is required but unsupported.
  • Learning mixin values — inspect capabilities alongside get-mixin.

🧠 How Compilation Works

1

Resolve a mixin value

Call meta.get-mixin("name") (or receive a mixin value as an argument).

Source
2

Ask accepts-content

Dart Sass inspects whether that mixin can take a @content block.

Compile
3

Branch your include

Use meta.apply with or without a content block based on the boolean.

Apply
4

Plain CSS ships

Browsers never see the check—only the finished CSS from the mixin.

⚠️ Common Pitfalls

  • Passing a string — use a mixin value from meta.get-mixin, not "panel" alone.
  • Reading true as “required”true means content is possible, not mandatory.
  • Skipping the guard — forwarding content to a non-accepting mixin can error; check first in generic helpers.
  • Old Dart Sass — need 1.69+ for mixin values and this function.
  • Confusing with functions — this inspects mixins; functions use meta.call, not content blocks.

💡 Best Practices

✅ Do

  • Use @use "sass:meta" and meta.accepts-content()
  • Resolve mixins with meta.get-mixin first
  • Guard content forwarding in higher-order helpers
  • Pair with meta.apply for dynamic includes
  • Prefer Dart Sass 1.69+

❌ Don’t

  • Expect the browser to evaluate meta.accepts-content
  • Pass a bare string as $mixin
  • Assume true means content is always consumed
  • Blindly attach @content to every meta.apply
  • Rely on LibSass / Ruby Sass for this API

Key Takeaways

Knowledge Unlocked

Five things to remember about meta.accepts-content()

Boolean capability check for mixin @content—Dart Sass 1.69+.

5
Core concepts
📦 02

Module

sass:meta

@use
03

Returns

true / false

Rule
04

Meaning

can accept content

Safe
05

Prefer

Dart Sass 1.69+

Tooling

❓ Frequently Asked Questions

meta.accepts-content($mixin) returns true or false for whether a mixin value can accept a @content block. Official docs: it returns true if accepting content is possible, even when the mixin does not always use @content.
A mixin value—usually from meta.get-mixin("name"), or from meta.module-mixins. Do not pass a plain string name.
When you write higher-order helpers that @include meta.apply($mixin) and sometimes forward @content. Check accepts-content first so you only pass a content block to mixins that support it.
No. true means it is possible for the mixin to accept content. The mixin might use @content only on some code paths.
meta.apply can forward a @content block into the applied mixin. meta.accepts-content tells you whether that is safe/possible for a given mixin value.
Dart Sass 1.69+. LibSass and Ruby Sass do not provide this helper. Prefer current Dart Sass.
Did you know?

Official Sass docs place meta.accepts-content with the other mixin-value tools that landed in Dart Sass 1.69—right beside meta.apply and meta.get-mixin—because dynamic includes often need a content capability check.

Conclusion

meta.accepts-content() is a small but important guard for dynamic mixin workflows: resolve a mixin value, ask whether @content is possible, then meta.apply with or without a content block. Load it through sass:meta on Dart Sass 1.69+.

Continue with meta.apply() or the Sass introduction.

Next: apply mixins dynamically

Learn meta.apply() to include mixin values with arguments and content.

meta.apply() →

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