Sass Introspection Functions
Sass Introspection functions are less commonly used for building stylesheets and are generally used for debugging code.
The following table lists the Sass Introspection functions:
Function | Description & Example |
---|---|
call(function, arguments...) | Dynamically calls a function with the specified arguments and returns the result. |
content-exists() | Checks if the current mixin passes a @content block. |
feature-exists(feature) | Checks if the current Sass implementation supports the specified feature. <br> <br> Example: <br>feature-exists("at-error"); <br>Result: true |
function-exists(functionname) | Checks if the specified function exists. <br> <br> Example: <br>function-exists("nonsense") <br>Result: false |
get-function(functionname, css: false) | Returns the specified function. If css is true, it returns a pure CSS function. |
global-variable-exists(variablename) | Checks if a global variable is defined. <br> <br> Example: <br>variable-exists(a) <br>Result: true |
inspect(value) | Returns a string representation of a Sass expression. |
mixin-exists(mixinname) | Checks if the specified mixin exists. <br> <br> Example: <br>mixin-exists("important-text") <br>Result: true |
type-of(value) | Returns the type of the value, which can be number, string, color, list, map, bool, null, function, arglist. <br> <br> Example: <br>type-of(15px) <br>Result: number <br>type-of(#ff0000) <br>Result: color |
unit(number) | Returns the unit (or compound unit) of the number. <br> <br> Example: <br>unit(15px) <br>Result: px |
unitless(number) | Returns a boolean indicating whether the number has a unit. <br> <br> Example: <br>unitless(15px) <br>Result: false <br>unitless(15) <br>Result: true |
variable-exists(variablename) | Checks if the variable exists in the current scope. <br> <br> Example: <br>variable-exists(b) <br>Result: true |