Sass Tutorial

Sass HOME Sass Intro Sass Installation Sass Variables Sass Nesting Sass @import Sass @mixin Sass @extend

Sass Functions

Sass String Sass Numeric Sass List Sass Map Sass Selector Sass Introspection Sass Color

Sass Exercises

Sass Quiz

Sass Introspection Functions

The introspection functions in this group allow you to examine the state of Sass itself.

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 Examples Result
variable-exists($name) Returns a Boolean value indicating whether the specified variable exists, either globally or in the current scope $a: 10px; true
variable-exists($not-declared) false
global-variable-exists($name) Returns a Boolean value indicating whether the specified variable exists at the global level $a: 10px;
global-variable-exists(a);
true
mixin-exists($name) Returns a Boolean value indicating whether the specified mixin exists @mixin text-color {color: red; } true
inspect($value) Returns $value as it is represented by Sass. inspect(12) "12"
type-of($value) Returns a string containing the Sass data type of $value type-of(1 2 3) "list"
unit($number) Returns the unit associated with a number, or an empty string if the number is unitless $a: 10px; "px"
$a: 10; ""
unitless($number) Returns a Boolean value indicating whether the specified number has a unit associated with it $a: 10px; false
comparable($number1, $number2) Returns a Boolean value indicating whether the specified numbers can be added, subtracted or compared comparable(1em, 4em) true
comparable(1em, 3px) false
comparable(1em, 5) true