The sass:meta module helps you check what kind of value you have and see its details. This is useful when you want to understand or debug your styles.
sass:meta module (type-of, inspect)
@use "sass:meta"; meta.type-of($value) meta.inspect($value)
type-of() returns the type of the value as a string like "string", "number", "color", etc.
inspect() returns a string showing the value in a readable way, useful for debugging.
$value, which is a number with units, so $type will be "number".@use "sass:meta"; $value: 10px; $type: meta.type-of($value);
$value to a string like "#ff0000" for easy reading.@use "sass:meta"; $value: #ff0000; $info: meta.inspect($value);
$value is a string, so type-of() returns "string".@use "sass:meta"; $value: "hello"; $type: meta.type-of($value);
This Sass code uses meta.type-of() to find the type of different values and meta.inspect() to get their readable string forms. The results are set as CSS properties so you can see them in the browser.
@use "sass:meta"; $color: #3498db; $size: 2rem; $text: "Sass Meta"; .type-check { color-type: meta.type-of($color); size-type: meta.type-of($size); text-type: meta.type-of($text); color-inspect: meta.inspect($color); size-inspect: meta.inspect($size); text-inspect: meta.inspect($text); }
Always @use "sass:meta"; before calling type-of() or inspect().
type-of() helps you write smarter styles by checking value types.
inspect() is great for debugging but usually not used in final CSS.
sass:meta helps you check and understand Sass values.
type-of() tells you the kind of value you have.
inspect() shows the value as a readable string.
Practice
type-of() do?Solution
Step 1: Understand the purpose of
This function returns the type of a given Sass value, like string, number, color, etc.type-of()Step 2: Compare options with the function's behavior
Only It tells you the kind of value you have in Sass. correctly describes that it tells the kind of value you have.Final Answer:
It tells you the kind of value you have in Sass. -> Option DQuick Check:
type-of() = tells value type [OK]
- Thinking type-of() changes the value type
- Confusing type-of() with output functions
- Assuming it converts Sass to CSS
inspect() on a Sass variable $color?Solution
Step 1: Recall correct function call syntax in Sass
Functions require parentheses around arguments and no semicolon inside the parentheses.Step 2: Check each option's syntax
inspect($color) usesinspect($color)which is correct. inspect($color); has an extra semicolon inside parentheses, B misses parentheses, D has incorrect parentheses placement.Final Answer:
inspect($color) -> Option AQuick Check:
Function calls need parentheses [OK]
- Omitting parentheses for function calls
- Adding semicolon inside function parentheses
- Misplacing parentheses after variable
$value: 10px; $result: type-of($value);What is the value of
$result?Solution
Step 1: Identify the type of
The value 10px is a number with a unit in Sass, so its type is "number".$valueStep 2: Understand what
It returns the type as a string, sotype-of()returns$resultwill be "number".Final Answer:
"number" -> Option BQuick Check:
10px is a number type [OK]
- Thinking units create a new type like 'length'
- Confusing string with number
- Assuming type-of returns the unit
$val: #ff0000; $result: inspect $val;
Solution
Step 1: Check function call syntax
In Sass, functions must be called with parentheses around arguments.Step 2: Identify the error in the code
The code usesinspect $val;without parentheses, which is invalid syntax.Final Answer:
Missing parentheses for the inspect function call. -> Option AQuick Check:
Functions need parentheses [OK]
- Calling functions without parentheses
- Assuming inspect can't handle colors
- Thinking semicolon is needed inside function call
type-of() and inspect() together?Solution
Step 1: Understand string interpolation in Sass
Use#{}to insert function results inside strings.Step 2: Check each option's correctness
@mixin debug($var) { content: "Type: #{type-of($var)}, Value: #{inspect($var)}"; } correctly callstype-of($var)andinspect($var)inside interpolation. @mixin debug($var) { content: "Type: type-of($var), Value: inspect($var)"; } treats functions as plain text. @mixin debug($var) { content: "Type: $var.type, Value: $var.inspect"; } uses invalid property access. @mixin debug($var) { content: "Type: #{inspect(type-of($var))}, Value: #{type-of(inspect($var))}"; } mixes function calls incorrectly.Final Answer:
@mixin debug($var) { content: "Type: #{type-of($var)}, Value: #{inspect($var)}"; } -> Option CQuick Check:
Use #{function()} for interpolation [OK]
- Not using interpolation for function calls
- Trying to access functions as properties
- Nesting functions incorrectly
Ready to prove it?
Pass the test and this pattern moves unknown
