Sass Introspection Functions
The introspection functions are rarely used when building a stylesheet. However, they are valuable if something does not work properly – to figure out what’s going on: like debugging functions.
The following table lists all introspection functions in Sass:
Function | Description & Example |
---|---|
call(function, arguments…) | Calls a function with arguments, and returns the result. |
content-exists() | Checks whether the current mixin was passed a @content block. |
feature-exists(feature) | Checks whether feature is supported by the current Sass implementation.
Example: |
function-exists(functionname) | Checks whether the specified function exists.
Example: |
get-function(functionname, css: false) | Returns the specified function. If css is true, it returns a plain CSS function instead. |
global-variable-exists(variablename) | Checks whether the specified global variable exists.
Example: |
inspect(value) | Returns a string representation of value. |
mixin-exists(mixinname) | Checks whether the specified mixin exists.
Example: |
type-of(value) | Returns the type of value. Can be number, string, color, list, map, bool, null, function, arglist.
Example: |
unit(number) | Returns the unit associated with a number.
Example: |
unitless(number) | Checks whether the specified number has a unit associated with it.
Example: |
variable-exists(variablename) | Checks whether the specified variable exists in the current scope.
Example: |