Every Sass value belongs to one of a small set of data types. This lesson covers numbers, strings, colors, booleans, null, lists, and maps, the foundation for understanding operators, control rules, and functions in later lessons.
What Data Types Does Sass Support?
Sass values fall into seven core types: numbers (with optional units), strings (quoted or unquoted), colors, booleans, null, lists, and maps. Unlike CSS, which treats most values as opaque text, Sass understands these types and lets you inspect, combine, and transform them with real logic.
Each of these values behaves differently in expressions, for example, you can add two numbers but not two colors the same way.
Type Checking Syntax
@use 'sass:meta';
meta.type-of($value)
meta.type-of() returns a value's type as a string: "number", "string", "color", "bool", "null", "list", or "map".
Numbers can carry a unit (16px) or be unitless (1.5).
Lists can be comma-separated or space-separated, and maps always use (key: value, ...) syntax.
null behaves like a falsy, empty placeholder value, similar to null in many programming languages.
Sass Data Types Cheatsheet
Every core Sass data type with a representative example.
Type
Example
Notes
Number
16px, 1.5, 100%
Can carry a unit or be unitless
String (quoted)
"Save Changes"
Preserves quotes in most contexts
String (unquoted)
bold, sans-serif
Common for CSS keyword values
Color
#2563eb, rgb(37 99 235)
Supports hex, functional, and named formats
Boolean
true, false
Used in @if and logical expressions
Null
null
Falsy, often used to "unset" a value
List
8px 16px, sm, md, lg
Space- or comma-separated values
Map
(sm: 8px, md: 16px)
Key-value pairs, always comma-separated
Numbers and Units
Sass numbers can be unitless or carry a CSS unit like px, rem, %, or deg. Arithmetic between numbers with compatible units works as expected, but Sass will raise an error if you try to add incompatible units, like 10px + 2em, without first converting them.
Both quoted ("Arial") and unquoted (Arial) strings are valid, and Sass treats them as largely interchangeable in most contexts. CSS keyword values like bold, sans-serif, or inherit are typically written unquoted.
$font-label: "Primary Font"; // quoted, useful for display text
$font-family: Arial, sans-serif; // unquoted, standard CSS keyword style
Null and Booleans
null is useful for representing "no value" and is commonly used as a default or a signal to skip outputting a declaration entirely. Booleans (true/false) drive conditional logic in @if statements.
@mixin border($color: null) {
@if $color {
border: 1px solid $color;
}
}
.plain-box {
@include border; // no border declaration output at all
}
Passing null (the default) means the @if check fails, and no border declaration is generated.
Common Mistakes
Trying to add numbers with incompatible units, like adding a percentage to a plain pixel value without conversion.
Assuming quoted and unquoted strings are always visually identical in every context; string interpolation and certain functions can behave slightly differently between them.
Confusing null with the string "null" or the number 0, they are distinct values with different truthy/falsy behavior.
Not checking a value's type with meta.type-of() before performing an operation on it inside a generic, reusable function.
Key Takeaways
Sass has seven core data types: numbers, strings, colors, booleans, null, lists, and maps.
Numbers can carry units; arithmetic requires compatible units.
null represents an absent value and is falsy in conditional checks.
meta.type-of() lets you inspect a value's type at compile time, useful for validation.
Pro Tip
Use null as a mixin's default parameter value whenever "no value provided" should mean "skip this declaration entirely", it's cleaner than checking against an arbitrary sentinel string or number.
You now understand every core Sass data type. Next, learn how Sass operators combine numbers, strings, colors, and booleans.