Sass Reflective Functions
- Previous Page Sass Selector
- Next Page Sass Color
Sass Reflective Functions
Introspection functions are rarely used when building style sheets.
However, if the code does not work properly, introspection functions are very valuable - they can help understand what went wrong: such as debugging functions.
The following table lists all the introspection functions in Sass:
Functions | Description & Example |
---|---|
call(function, arguments...) | Call a function with parameters and return the result. |
content-exists() | Check if the current mixin has been passed an @content block. |
feature-exists(feature) |
Check if the current Sass implementation supports this feature. Example:feature-exists("at-error"); Result: true |
function-exists(functionname) |
Check if the specified function exists. Example:function-exists("nonsense") Result: false |
get-function(functionname, css: false) | Return the specified function. If css is true, it will return a regular CSS function. |
global-variable-exists(variablename) |
Check if the specified global variable exists. Example:variable-exists(a) Result: true |
inspect(value) | Return the string representation of the value. |
mixin-exists(mixinname) |
Check if the specified mixin exists. Example:mixin-exists("important-text") Result: true |
type-of(value) |
Return the type of the value. It can be:
Example:type-of(15px) Result: number type-of(#ff0000) Result: color |
unit(number) |
Return the unit associated with the number. Example:unit(15px) Result: px |
unitless(number) |
Check if the specified number has an associated unit. Example:unitless(15px) Result: false unitless(15) Result: true |
variable-exists(variablename) |
Check if the specified variable exists in the current scope. Example:variable-exists(b) Result: true |
- Previous Page Sass Selector
- Next Page Sass Color