Sass property declarations style matching elements like CSS—with SassScript values, nested prefixes, interpolated names, optional (hidden) declarations, and special rules for CSS custom properties. Five compiled examples follow.
01
Values
Any SassScript
02
#{ } names
Dynamic props
03
Nesting
font- / margin-
04
Hidden
null → omit
05
--custom
Interpolate only
06
Practice
5 examples
Concept
What Are Property Declarations?
Official docs: in Sass as in CSS, declarations define how elements that match a selector are styled. Sass makes them easier to write and automate—first and foremost, a declaration’s value can be any SassScript expression, evaluated into the CSS result.
Use variables, math, functions, and lists as values.
Nest related longhands under a shared prefix.
Build property names with #{ } when needed.
Skip emitting a property when its value is null (or an empty unquoted string).
💡
Beginner tip
For normal properties, write color: $brand;—not color: #{$brand};. Save interpolation for names, paths, and CSS custom properties.
A property’s name can include interpolation so you can generate vendor prefixes or entire property identifiers dynamically.
Nesting
🏷️ Nested Properties
Many CSS properties share a prefix namespace (font-, transition-, margin-). Nest the inner parts; Sass joins them with a hyphen.
For shorthands that use the same name as the namespace, you can write the shorthand value and nest more specific longhands underneath.
Optional
👁️ Hidden Declarations
If a declaration’s value is null or an empty unquoted string, Sass does not compile that declaration to CSS. Pair this with if($condition, $value, null) to toggle properties cleanly.
CSS Variables
🎨 Custom Properties (--)
CSS custom properties allow almost any text as a value (and JS can read them). Because of that, Sass parses them differently: tokens that look like SassScript are passed through as-is. The only way to inject dynamic Sass values is interpolation.
⚠️
Heads up — quotes
Interpolation removes quotes from strings. To keep quoted lists (for example font stacks) intact inside --* properties, wrap the value with meta.inspect($value) inside #{ }.
Note: the plain-CSS @functionresult property is parsed like a custom property (interpolation required) in Dart Sass 1.94.0+. Older compilers (including many 1.69.x installs) may not support that API yet.
Cheat Sheet
⚡ Quick Reference
Goal
Code
Use a variable
color: $brand;
Math in a value
width: $size * 0.5;
Nest a prefix
font: { size: 1rem; weight: 700; }
Shorthand + nest
margin: auto { top: 2px; }
Dynamic name
#{$property}: $value;
Optional property
border-radius: if($on, 5px, null);
CSS variable from Sass
--primary: #{$primary};
Keep quotes in --
--fonts: #{meta.inspect($stack)};
Hands-On
Examples Gallery
Each example is verified with Dart Sass. Open View Compiled CSS for output.
Hide bugs by omitting properties accidentally with null
Wrap every value in #{ } “just in case”
Forget meta.inspect when quoted stacks must survive
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about property declarations
Values, names, nests, nulls, and custom properties.
5
Core concepts
📝01
SassScript
any expression
Values
🔢02
#{ } names
dynamic props
Names
🏷️03
Nest prefixes
less repetition
Nest
👁️04
null hides
no CSS line
Optional
🎨05
--needs #{ }
custom props
CSS vars
❓ Frequently Asked Questions
Like CSS, they set how matching elements look (color, width, and so on). Sass lets the value be any SassScript expression, and adds nesting, interpolation, and smarter custom-property parsing.
Write a shared prefix once, then nest the rest. transition: { property: font-size; } becomes transition-property: font-size. You can also set a shorthand and nest longhands under it.
Yes. Interpolate with #{ } in the property name, for example -#{$prefix}-#{$property}: $value; or even #{$property}: $value;
If the value is null or an empty unquoted string, Sass does not emit that declaration. Useful with if($flag, 5px, null).
Values are passed through almost as raw CSS. SassScript is not evaluated unless you use interpolation. So --x: $primary; keeps the text $primary; use --x: #{$primary}; to inject the variable.
Interpolation strips quotes from strings. Use meta.inspect($value) inside #{ } so quoted strings stay quoted in the CSS custom property.
Did you know?
Official Sass docs recommend using interpolation for custom property values even on older LibSass/Ruby Sass versions that once evaluated SassScript there—so your styles stay forward-compatible with modern Dart Sass parsing.
Sass property declarations extend CSS with expressive values, nested prefixes, optional output, and careful custom-property rules. Use SassScript for normal props and #{ } when the CSS text itself must change.