Introspection Functions

call($function, $args...) 
Compatibility (Argument Type):
Dart Sass
LibSass
since 3.5.0
Ruby Sass
since 3.5.0

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 should be a function returned by get-function().

SCSS Syntax

/// Return a copy of $list with all elements for which $condition returns `true`
/// removed.
@function remove-where($list, $condition) {
  $new-list: ();
  $separator: list-separator($list);
  @each $element in $list {
    @if not call($condition, $element) {
      $new-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 str-index($string, "Helvetica");
  }
  font-family: remove-where($fonts, get-function("contains-helvetica"));
}

Sass Syntax

/// Return a copy of $list with all elements for which $condition returns `true`
/// removed.
@function remove-where($list, $condition)
  $new-list: ()
  $separator: list-separator($list)
  @each $element in $list
    @if not call($condition, $element)
      $new-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 str-index($string, "Helvetica")

  font-family: remove-where($fonts, get-function("contains-helvetica"))

CSS Output

content {
  font-family: Tahoma, Geneva, Arial, sans-serif;
}


















content-exists() //=> boolean 

Returns whether the current mixin was passed a @content block.

Throws an error if called outside of a mixin.

SCSS Syntax

@mixin debug-content-exists {
  @debug content-exists();
  @content;
}

@include debug-content-exists; // false
@include debug-content-exists { // true
  // Content!
}

Sass Syntax

@mixin debug-content-exists
  @debug content-exists()
  @content


@include debug-content-exists  // false
@include debug-content-exists   // true
  // Content!

feature-exists($feature) //=> boolean 

Returns whether the current Sass implementation supports $feature.

The $feature must be a string. The currently recognized features are:

Returns false for any unrecognized $feature.

SCSS Syntax

@debug feature-exists("at-error"); // true
@debug feature-exists("unrecognized"); // false

Sass Syntax

@debug feature-exists("at-error")  // true
@debug feature-exists("unrecognized")  // false
function-exists($name) //=> boolean 

Returns whether a function named $name is defined, either as a built-in function or a user-defined function.

SCSS Syntax

@debug function-exists("scale-color"); // true
@debug function-exists("add"); // false

@function add($num1, $num2) {
  @return $num1 + $num2;
}
@debug function-exists("add"); // true

Sass Syntax

@debug function-exists("scale-color")  // true
@debug function-exists("add")  // false

@function add($num1, $num2)
  @return $num1 + $num2

@debug function-exists("add")  // true
get-function($name, $css: false) //=> function 

Returns the function named $name.

This can access both built-in and user-defined functions. By default, it throws an error if $name doesn’t refer to either a built-in or user-defined function. However, if $css is true, it instead returns a plain CSS function.

The returned function can be called using call().

SCSS Syntax

/// Return a copy of $list with all elements for which $condition returns `true`
/// removed.
@function remove-where($list, $condition) {
  $new-list: ();
  $separator: list-separator($list);
  @each $element in $list {
    @if not call($condition, $element) {
      $new-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 str-index($string, "Helvetica");
  }
  font-family: remove-where($fonts, get-function("contains-helvetica"));
}

Sass Syntax

/// Return a copy of $list with all elements for which $condition returns `true`
/// removed.
@function remove-where($list, $condition)
  $new-list: ()
  $separator: list-separator($list)
  @each $element in $list
    @if not call($condition, $element)
      $new-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 str-index($string, "Helvetica")

  font-family: remove-where($fonts, get-function("contains-helvetica"))

CSS Output

content {
  font-family: Tahoma, Geneva, Arial, sans-serif;
}


















global-variable-exists($name) //=> boolean 

Returns whether a global variable named $name (without the $) exists.

See also variable-exists().

SCSS Syntax

@debug global-variable-exists("var1"); // false

$var1: value;
@debug global-variable-exists("var1"); // true

h1 {
  // $var2 is local.
  $var2: value;
  @debug global-variable-exists("var2"); // false
}

Sass Syntax

@debug global-variable-exists("var1")  // false

$var1: value 
@debug global-variable-exists("var1")  // true

h1
  // $var2 is local.
  $var2: value
  @debug global-variable-exists("var2")  // false

inspect($value) //=> unquoted string 

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.

SCSS Syntax

@debug inspect(10px 20px 30px); // unquote("10px 20px 30px")
@debug inspect(("width": 200px)); // unquote('("width": 200px)')
@debug inspect(null); // unquote("null")
@debug inspect("Helvetica"); // unquote('"Helvetica"')

Sass Syntax

@debug inspect(10px 20px 30px)  // unquote("10px 20px 30px")
@debug inspect(("width": 200px))  // unquote('("width": 200px)')
@debug inspect(null)  // unquote("null")
@debug inspect("Helvetica")  // unquote('"Helvetica"')
mixin-exists($name) //=> boolean 

Returns whether a mixin named $name exists.

SCSS Syntax

@debug mixin-exists("shadow-none"); // false

@mixin shadow-none {
  box-shadow: none;
}

@debug mixin-exists("shadow-none"); // true

Sass Syntax

@debug mixin-exists("shadow-none")  // false

@mixin shadow-none
  box-shadow: none


@debug mixin-exists("shadow-none")  // true
type-of($value) //=> unquoted string 

Returns the type of $value.

This can return the following values:

New possible values may be added in the future. It may return either list or map for (), depending on whether or not it was returned by a map function.

SCSS Syntax

@debug type-of(10px); // number
@debug type-of(10px 20px 30px); // list
@debug type-of(()); // list

Sass Syntax

@debug type-of(10px)  // number
@debug type-of(10px 20px 30px)  // list
@debug type-of(())  // list
variable-exists($name) //=> boolean 

Returns whether a variable named $name (without the $) exists in the current scope.

See also global-variable-exists().

SCSS Syntax

@debug variable-exists("var1"); // false

$var1: value;
@debug variable-exists("var1"); // true

h1 {
  // $var2 is local.
  $var2: value;
  @debug variable-exists("var2"); // true
}

Sass Syntax

@debug variable-exists("var1")  // false

$var1: value 
@debug variable-exists("var1")  // true

h1
  // $var2 is local.
  $var2: value
  @debug variable-exists("var2")  // true