Compatibility:
Only Dart Sass currently supports loading built-in modules with @use
. Users of other implementations must call functions using their global names instead.
meta.apply($mixin, $args...)
Compatibility:
Includes $mixin
with $args
. If this is passed a @content
block, it’s forwarded to $mixin
.
The $mixin
must be a mixin value, such as one returned by meta.get-mixin()
.
meta.load-css($url, $with: null)
Compatibility:
Only Dart Sass currently supports this mixin.
Loads the module at $url
and includes its CSS as though it were written as the contents of this mixin. The $with
parameter provides configuration for the modules; if it’s passed, it must be a map from variable names (without $
) to the values of those variables to use in the loaded module.
If $url
is relative, it’s interpreted as relative to the file in which meta.load-css()
is included.
Like the @use
rule:
This will only evaluate the given module once, even if it’s loaded multiple times in different ways.
This cannot provide configuration to a module that’s already been loaded, whether or not it was already loaded with configuration.
Unlike the @use
rule:
This doesn’t make any members from the loaded module available in the current module.
This can be used anywhere in a stylesheet. It can even be nested within style rules to create nested styles!
The module URL being loaded can come from a variable and include interpolation.
The $url
parameter should be a string containing a URL like you’d pass to the @use
rule. It shouldn’t be a CSS url()
!
$border-contrast: false !default;
code {
background-color: #6b717f;
color: #d2e1dd;
@if $border-contrast {
border-color: #dadbdf;
}
}
@use "sass:meta";
body.dark {
@include meta.load-css("dark-theme/code",
$with: ("border-contrast": true));
}
Sass Syntax
$border-contrast: false !default
code
background-color: #6b717f
color: #d2e1dd
@if $border-contrast
border-color: #dadbdf
@use "sass:meta"
body.dark
$configuration: ("border-contrast": true)
@include meta.load-css("dark-theme/code", $with: $configuration)
CSS Output
body.dark code {
background-color: #6b717f;
color: #d2e1dd;
border-color: #dadbdf;
}
FunctionsFunctions permalink
meta.accepts-content($mixin)
Compatibility:
Returns whether the given mixin value can accept a @content
block.
This returns true if it’s possible for the mixin to accept a @content
block, even if it doesn’t always do so.
meta.calc-args($calc)
Compatibility:
Returns the arguments for the given calculation.
If an argument is a number or a nested calculation, it’s returned as that type. Otherwise, it’s returned as an unquoted string.
meta.calc-name($calc)
Compatibility:
Returns the name of the given calculation.
meta.call($function, $args...)
call($function, $args...)
Compatibility (Argument Type):
In older versions of LibSass and Ruby Sass, the call()
function took a string representing a function’s name. This was changed to take a function value instead in preparation for a new module system where functions are no longer global and so a given name may not always refer to the same function.
Passing a string to call()
still works in all implementations, but it’s deprecated and will be disallowed in future versions.
Invokes $function
with $args
and returns the result.
The $function
must be a function value, such as one returned by meta.get-function()
.
@use "sass:list";
@use "sass:meta";
@use "sass:string";
@function remove-where($list, $condition) {
$new-list: ();
$separator: list.separator($list);
@each $element in $list {
@if not meta.call($condition, $element) {
$new-list: list.append($new-list, $element, $separator: $separator);
}
}
@return $new-list;
}
$fonts: Tahoma, Geneva, "Helvetica Neue", Helvetica, Arial, sans-serif;
.content {
@function contains-helvetica($string) {
@return string.index($string, "Helvetica");
}
font-family: remove-where($fonts, meta.get-function("contains-helvetica"));
}
Playground Sass Syntax
@use "sass:list"
@use "sass:meta"
@use "sass:string"
@function remove-where($list, $condition)
$new-list: ()
$separator: list.separator($list)
@each $element in $list
@if not meta.call($condition, $element)
$new-list: list.append($new-list, $element, $separator: $separator)
@return $new-list
$fonts: Tahoma, Geneva, "Helvetica Neue", Helvetica, Arial, sans-serif
.content
@function contains-helvetica($string)
@return string.index($string, "Helvetica")
font-family: remove-where($fonts, meta.get-function("contains-helvetica"))
CSS Output
.content {
font-family: Tahoma, Geneva, Arial, sans-serif;
}
meta.content-exists()
content-exists()
Returns whether the current mixin was passed a @content
block.
Throws an error if called outside of a mixin.
meta.feature-exists($feature)
feature-exists($feature)
Returns whether the current Sass implementation supports $feature
.
The $feature
must be a string. The currently recognized features are:
global-variable-shadowing
, which means that a local variable will shadow a global variable unless it has the !global
flag.extend-selector-pseudoclass
, which means that the @extend
rule will affect selectors nested in pseudo-classes like :not()
.units-level3
, which means that unit arithmetic supports units defined in CSS Values and Units Level 3.at-error
, which means that the @error
rule is supported.custom-property
, which means that custom property declaration values don’t support any expressions other than interpolation.Returns false
for any unrecognized $feature
.
meta.function-exists($name, $module: null)
function-exists($name)
Returns whether a function named $name
is defined, either as a built-in function or a user-defined function.
If $module
is passed, this also checks the module named $module
for the function definition. $module
must be a string matching the namespace of a @use
rule in the current file.
meta.get-function($name, $css: false, $module: null)
get-function($name, $css: false, $module: null)
Returns the function value named $name
.
If $module
is null
, this returns the function named $name
without a namespace (including global built-in functions). Otherwise, $module
must be a string matching the namespace of a @use
rule in the current file, in which case this returns the function in that module named $name
.
By default, this throws an error if $name
doesn’t refer to Sass function. However, if $css
is true
, it instead returns a plain CSS function.
The returned function can be called using meta.call()
.
@use "sass:list";
@use "sass:meta";
@use "sass:string";
@function remove-where($list, $condition) {
$new-list: ();
$separator: list.separator($list);
@each $element in $list {
@if not meta.call($condition, $element) {
$new-list: list.append($new-list, $element, $separator: $separator);
}
}
@return $new-list;
}
$fonts: Tahoma, Geneva, "Helvetica Neue", Helvetica, Arial, sans-serif;
.content {
@function contains-helvetica($string) {
@return string.index($string, "Helvetica");
}
font-family: remove-where($fonts, meta.get-function("contains-helvetica"));
}
Playground Sass Syntax
@use "sass:list"
@use "sass:meta"
@use "sass:string"
@function remove-where($list, $condition)
$new-list: ()
$separator: list.separator($list)
@each $element in $list
@if not meta.call($condition, $element)
$new-list: list.append($new-list, $element, $separator: $separator)
@return $new-list
$fonts: Tahoma, Geneva, "Helvetica Neue", Helvetica, Arial, sans-serif
.content
@function contains-helvetica($string)
@return string.index($string, "Helvetica")
font-family: remove-where($fonts, meta.get-function("contains-helvetica"))
CSS Output
.content {
font-family: Tahoma, Geneva, Arial, sans-serif;
}
meta.get-mixin($name, $module: null)
Compatibility:
Returns the mixin value named $name
.
If $module
is null
, this returns the mixin named $name
defined in the current module. Otherwise, $module
must be a string matching the namespace of a @use
rule in the current file, in which case this returns the mixin in that module named $name
.
By default, this throws an error if $name
doesn’t refer to a mixin.
The returned mixin can be included using meta.apply()
.
meta.global-variable-exists($name, $module: null)
global-variable-exists($name, $module: null)
Returns whether a global variable named $name
(without the $
) exists.
If $module
is null
, this returns whether a variable named $name
without a namespace exists. Otherwise, $module
must be a string matching the namespace of a @use
rule in the current file, in which case this returns whether that module has a variable named $name
.
See also meta.variable-exists()
.
meta.inspect($value)
inspect($value)
Returns a string representation of $value
.
Returns a representation of any Sass value, not just those that can be represented in CSS. As such, its return value is not guaranteed to be valid CSS.
⚠️ Heads up!This function is intended for debugging; its output format is not guaranteed to be consistent across Sass versions or implementations.
meta.keywords($args)
keywords($args)
Returns the keywords passed to a mixin or function that takes arbitrary arguments. The $args
argument must be an argument list.
The keywords are returned as a map from argument names as unquoted strings (not including $
) to the values of those arguments.
meta.mixin-exists($name, $module: null)
mixin-exists($name, $module: null)
Returns whether a mixin named $name
exists.
If $module
is null
, this returns whether a mixin named $name
without a namespace exists. Otherwise, $module
must be a string matching the namespace of a @use
rule in the current file, in which case this returns whether that module has a mixin named $name
.
meta.module-functions($module)
Compatibility:
Only Dart Sass currently supports this function.
Returns all the functions defined in a module, as a map from function names to function values.
The $module
parameter must be a string matching the namespace of a @use
rule in the current file.
@function pow($base, $exponent) {
$result: 1;
@for $_ from 1 through $exponent {
$result: $result * $base;
}
@return $result;
}
@use "sass:map";
@use "sass:meta";
@use "functions";
@debug meta.module-functions("functions");
@debug meta.call(map.get(meta.module-functions("functions"), "pow"), 3, 4);
Sass Syntax
@function pow($base, $exponent)
$result: 1
@for $_ from 1 through $exponent
$result: $result * $base
@return $result
@use "sass:map"
@use "sass:meta"
@use "functions"
@debug meta.module-functions("functions") // ("pow": get-function("pow"))
@debug meta.call(map.get(meta.module-functions("functions"), "pow"), 3, 4) // 81
meta.module-mixins($module)
Compatibility:
Returns all the mixins defined in a module, as a map from mixin names to mixin values.
The $module
parameter must be a string matching the namespace of a @use
rule in the current file.
@mixin stretch() {
align-items: stretch;
display: flex;
flex-direction: row;
}
@use "sass:map";
@use "sass:meta";
@use "mixins";
@debug meta.module-mixins("mixins");
.header {
@include meta.apply(map.get(meta.module-mixins("mixins"), "stretch"));
}
Sass Syntax
@mixin stretch()
align-items: stretch
display: flex
flex-direction: row
@use "sass:map"
@use "sass:meta"
@use "mixins"
@debug meta.module-mixins("mixins") // => ("stretch": get-mixin("stretch"))
.header
@include meta.apply(map.get(meta.module-mixins("mixins"), "stretch"))
CSS Output
.header {
align-items: stretch;
display: flex;
flex-direction: row;
}
meta.module-variables($module)
Compatibility:
Only Dart Sass currently supports this function.
Returns all the variables defined in a module, as a map from variable names (without $
) to the values of those variables.
The $module
parameter must be a string matching the namespace of a @use
rule in the current file.
$hopbush: #c69;
$midnight-blue: #036;
$wafer: #e1d7d2;
@use "sass:meta";
@use "variables";
@debug meta.module-variables("variables");
Sass Syntax
$hopbush: #c69
$midnight-blue: #036
$wafer: #e1d7d2
@use "sass:meta"
@use "variables"
@debug meta.module-variables("variables")
meta.variable-exists($name)
variable-exists($name)
Returns whether a variable named $name
(without the $
) exists in the current scope.
See also meta.global-variable-exists()
.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4