Sass meta.load()

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

Definition and Usage

meta.load($url, $with: null) loads the stylesheet at $url and returns a module value. The module is evaluated once, but no CSS is emitted until you ask for it with @include meta.css($module).

Load it with @use "sass:meta". Requires Dart Sass 1.105+.

Value, not include.

Unlike @use, meta.load() does not create a namespace. You keep the module in a variable and pass it to functions such as meta.module-variables() or meta.get-function(..., $module: $m).

$with configures !default variables.

Pass a map from variable names (no $) to values. It works only the first time a module is loaded.

Already loaded means locked.

If the same file was already loaded (by @use, @forward, or another meta.load), you cannot configure it again.

Syntax

SCSS
@use "sass:meta";

meta.load($url, $with: null); //=> module

$theme: meta.load("theme");
$custom: meta.load("other", $with: ("primary": #c6538c));

@include meta.css($theme);              // emit its CSS where you want
meta.module-variables($theme);          // map of variables

// Module API — Dart Sass 1.105+

Pattern: meta.load → keep the module value → read members or @include meta.css to emit its CSS. Compare with meta.load-css() which loads and emits in one step.

load vs @use vs load-css

Three ways to bring a stylesheet in:

ToolGives youCSS emitted
@use "url"Namespace for membersOnce, at the @use
meta.load($url)A module valueNo (until meta.css)
@include meta.load-css($url)Nothing (CSS only)Yes, where included
@include meta.css($module)Nothing (CSS only)Yes, each time it is included
Shorthand.

meta.load-css($url) is the same as meta.css(meta.load($url)).

SCSS Examples

Examples target Dart Sass 1.105+ with @use "sass:meta". Helper files are shown above each main file. Open View Compiled CSS to see the result.

Example 1 — Load a Module and Inspect It

Loading returns a module value and emits no CSS.

SCSS
$primary: #036 !default;
$radius: 4px !default;

.theme {
  color: $primary;
}
SCSS
@use "sass:meta";

$theme: meta.load("theme");

.info {
  --type: #{meta.type-of($theme)};
  --inspect: #{meta.inspect($theme)};
}

How It Works

  1. meta.load("theme") loads _theme.scss and returns a module.
  2. .theme is not emitted—loading alone outputs no CSS.
  3. meta.type-of reports module.
  4. meta.inspect prints get-module("theme").

Example 2 — Read Variables from a Loaded Module

Pair meta.load() with meta.module-variables().

SCSS
$primary: #036 !default;
$radius: 4px !default;

.theme {
  color: $primary;
}
SCSS
@use "sass:map";
@use "sass:meta";

$theme: meta.load("theme");
$vars: meta.module-variables($theme);

.card {
  color: map.get($vars, "primary");
  border-radius: map.get($vars, "radius");
}

How It Works

  1. meta.module-variables accepts a module value.
  2. Keys are variable names without $.
  3. map.get reads each value.
  4. No namespace was needed.

Example 3 — Configure with $with and Emit with meta.css

Override a !default variable while loading.

SCSS
$primary: #036 !default;
$radius: 4px !default;

.theme {
  color: $primary;
}
SCSS
@use "sass:meta";

$theme: meta.load("theme", $with: ("primary": #c6538c));

@include meta.css($theme);

How It Works

  1. $with replaces $primary before the module is evaluated.
  2. @include meta.css($theme) emits the module CSS.
  3. .theme now uses #c6538c.
  4. Variables without !default cannot be configured.

Example 4 — Call a Function from a Loaded Module

Use the module value as $module for get-function.

SCSS
@use "sass:math";

@function rem($px) {
  @return math.div($px, 16px) * 1rem;
}
SCSS
@use "sass:meta";

$utils: meta.load("utils");
$rem: meta.get-function("rem", $module: $utils);

.title {
  font-size: meta.call($rem, 24px);
}

How It Works

  1. meta.load("utils") loads the helper file.
  2. meta.get-function("rem", $module: $utils) resolves the function.
  3. meta.call($rem, 24px) returns 1.5rem.
  4. No @use namespace is required.

Example 5 — Configuration After the First Load Fails

A module cannot be reconfigured once it has been loaded.

SCSS
$primary: #036 !default;
$radius: 4px !default;

.theme {
  color: $primary;
}
SCSS
@use "sass:meta";

$first: meta.load("theme");
$second: meta.load("theme", $with: ("primary": red));

How It Works

  1. The first load evaluates _theme.scss with its defaults.
  2. The second load tries to apply $with to the same module.
  3. Sass rejects it because the module was already loaded.
  4. Fix: pass $with on the very first load.

Edge Cases & Pitfalls

Most meta.load issues are expecting CSS from a plain load, or configuring too late.

css

No CSS without meta.css

Loading evaluates the file but stays silent. Add @include meta.css($module) or use meta.load-css().

with

Configure on the first load

Reconfiguring a module that is already loaded is an error. Load it once with $with.

url

URL not found

A missing stylesheet fails with a normal "Can’t find stylesheet" error. Check load paths and partial names.

ns

No namespace is created

Unlike @use, meta.load() does not bind a namespace. Keep the returned value in a variable.

Sass Support

Part of the first-class module support in recent Dart Sass.

APIStatus
meta.load()Dart Sass 1.105+ via @use "sass:meta"
Return typeModule value
$withMap of !default variable names to values
LibSass / Ruby SassNot supported

Compile with the Dart Sass CLI.

Key Takeaways

  • Loads a stylesheet and returns a module value.
  • Emits no CSS by itself—use meta.css() to output it.
  • $with configures !default variables on the first load.
  • Module values work as $module in other meta functions.

One line: use meta.load($url) when you want a stylesheet as a value instead of a namespace.

Compile Notes

Practical checklist:

checklist.txt
1. @use "sass:meta"
2. $m: meta.load("url") (no CSS yet)
3. Pass $with on the first load only
4. @include meta.css($m) to emit its CSS
5. Pass $m as $module to other meta functions

Frequently Asked Questions

meta.load($url, $with: null) loads the stylesheet at $url and returns a module value. It evaluates the stylesheet once but does not emit its CSS.
Use @include meta.css($module). The shorthand @include meta.load-css($url) loads and emits in one step.
@use creates a namespace for members and emits the CSS once. meta.load returns a module value, creates no namespace, and emits no CSS by itself.
Yes, with the $with map, but only on the first load. Once a module has been loaded it cannot be configured again.
Pass it as $module to meta.get-function(), meta.get-mixin(), meta.module-variables(), meta.module-functions(), or meta.module-mixins(), or include its CSS with meta.css().
Dart Sass 1.105 and later. LibSass and Ruby Sass do not provide first-class modules.

Next: Sass meta.mixin-exists()

Check whether a mixin is defined before using it.

meta.mixin-exists() →

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