Sass meta.accepts-content()

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

Definition and Usage

meta.accepts-content($mixin) returns a boolean: whether the given 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. Load it with @use "sass:meta" on Dart Sass 1.69+.

Typical inputs.

Pass a mixin value from meta.get-mixin() or meta.module-mixins()—not a plain string name.

Higher-order mixins.

Use this before meta.apply() when a helper sometimes forwards @content and sometimes does not.

Not the same as content-exists.

accepts-content asks “can this mixin take content?” meta.content-exists() asks “did the current include pass content?”

Syntax

SCSS
@use "sass:meta";

meta.accepts-content($mixin); //=> boolean

@mixin plain($n) { width: $n; }
@mixin wrap { @content; }

meta.accepts-content(meta.get-mixin("plain")); // false
meta.accepts-content(meta.get-mixin("wrap"));  // true

// Module API — prefer meta.accepts-content after @use "sass:meta"

Pattern: get a mixin value → check accepts-content → branch before meta.apply with or without a content block.

accepts-content vs content-exists

Two related helpers, different questions:

HelperAsksWhere
meta.accepts-content($mixin)Can this mixin value take @content?Anywhere you have a mixin value
meta.content-exists()Did this include pass a content block?Only inside a mixin
true from accepts-contentContent is possible (even if conditional)Not “always uses @content”
falseNo @content slotDo not forward a content block
Conditional @content.

A mixin that only calls @content inside @if still returns true—accepting content is possible.

SCSS Examples

Examples target Dart Sass 1.69+ with @use "sass:meta". Open View Compiled CSS for verified output.

Example 1 — Mixin Without @content

A plain mixin returns false.

SCSS
@use "sass:meta";

@mixin box($padding) {
  padding: $padding;
}

.basic {
  --accepts: #{meta.accepts-content(meta.get-mixin("box"))};
}

How It Works

  1. box has no @content.
  2. get-mixin returns a mixin value.
  3. accepts-content is false.
  4. Do not forward a content block into it.

Example 2 — Mixin With @content

A wrapper that includes @content returns true.

SCSS
@use "sass:meta";

@mixin media($query) {
  @media #{$query} {
    @content;
  }
}

.true-case {
  --accepts: #{meta.accepts-content(meta.get-mixin("media"))};
}

How It Works

  1. media declares @content.
  2. Accepting content is possible.
  3. Result is true.
  4. Safe to forward a content block via meta.apply.

Example 3 — Conditional @content Still Counts

Official idea: true if content is possible, even when not always used.

SCSS
@use "sass:meta";

@mixin maybe($flag) {
  @if $flag {
    @content;
  }
}

.conditional {
  --accepts: #{meta.accepts-content(meta.get-mixin("maybe"))};
}

How It Works

  1. @content sits behind @if.
  2. Capability still exists.
  3. Returns true.
  4. Not a guarantee that content always runs.

Example 4 — Guard meta.apply

Forward a content block only when the target mixin accepts one.

SCSS
@use "sass:meta";

@mixin plain {
  color: blue;
}

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

@mixin apply-if-content($mixin) {
  @if meta.accepts-content($mixin) {
    @include meta.apply($mixin) {
      outline: 1px solid red;
    }
  } @else {
    @include meta.apply($mixin);
  }
}

.a {
  @include apply-if-content(meta.get-mixin("plain"));
}

.b {
  @include apply-if-content(meta.get-mixin("with-content"));
}

How It Works

  1. Check accepts-content first.
  2. plain gets apply without content.
  3. with-content receives the outline block.
  4. Avoids forwarding content into mixins that cannot take it.

Example 5 — Contrast with meta.content-exists

Capability vs whether content was passed on this include.

SCSS
@use "sass:meta";

@mixin wrap {
  --can: #{meta.accepts-content(meta.get-mixin("wrap"))};
  --passed: #{meta.content-exists()};
  @content;
}

.no-block {
  @include wrap;
}

.with-block {
  @include wrap {
    color: green;
  }
}

How It Works

  1. --can stays true for both includes.
  2. --passed depends on the caller.
  3. accepts-content is about the mixin definition.
  4. content-exists is about this include call.

Edge Cases & Pitfalls

Most mistakes are passing a string name or confusing capability with “content was passed.”

type

Pass a mixin value

Use meta.get-mixin("name"). A bare string is not a mixin value.

true

true ≠ always uses content

Conditional @content still reports true. Capability is not a runtime guarantee.

vs

Wrong helper for “was content passed?”

Inside a mixin, use meta.content-exists().

version

Needs Dart Sass 1.69+

Older compilers and LibSass / Ruby Sass do not provide this API.

Sass Support

Prefer the module form with Dart Sass 1.69+.

APIStatus
meta.accepts-content()Dart Sass 1.69+ via @use "sass:meta"
ArgumentMixin value (e.g. from meta.get-mixin)
Return typeBoolean
LibSass / Ruby SassNot available

Compile with the Dart Sass CLI.

Key Takeaways

  • Boolean capability check for mixin @content.
  • Pass a mixin value from get-mixin / module maps.
  • Guard meta.apply before forwarding content.
  • Dart Sass 1.69+ via @use "sass:meta".

One line: when you need to know if a mixin value can take @content before applying it, call meta.accepts-content($mixin).

Compile Notes

Practical checklist:

checklist.txt
1. @use "sass:meta"
2. Get a mixin value (meta.get-mixin / module-mixins)
3. Call meta.accepts-content($mixin)
4. Branch before meta.apply with or without @content
5. Use content-exists() inside mixins for "was content passed?"

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.

Next: Sass meta.apply()

Include a mixin value and optionally forward @content.

meta.apply() →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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