Sass Property Declarations

Beginner
9 min read
Updated: Nov 2026
5 examples
Dart Sass

Definition and Usage

Property declarations style matching elements—same idea as CSS. Sass adds SassScript values, nested property names, interpolated names, and special rules for CSS custom properties.

Any SassScript value.

width: $size; and border-radius: $size * 0.5; are evaluated before CSS is emitted.

Nest shared prefixes.

transition: { property: font-size; } becomes transition-property: font-size.

Custom properties need #{ }.

--x: $primary; keeps the text $primary. Use --x: #{$primary}; to inject the value.

Syntax

SCSS
.circle {
  $size: 100px;
  width: $size;                 // SassScript value
  border-radius: $size * 0.5;
}

.enlarge {
  transition: {                // nested names → transition-*
    property: font-size;
    duration: 4s;
  }
}

.gray {
  -#{$prefix}-filter: ...;     // interpolated property name
}

:root {
  --primary: #{$primary};      // custom props: interpolate to inject
  border-radius: null;         // omitted from CSS
}

Pattern: write name: value; → evaluate SassScript → nest or interpolate names when useful → omit null values.

Common Patterns

What you will use most often:

PatternResult idea
width: $size * 2;SassScript expression as the value
font: { size: 14px; }Nested → font-size
margin: auto { top: 2px; }Shorthand + nested longhands
#{$prop}: $value;Dynamic property name
radius: null;Declaration omitted from CSS
--x: #{$v};Inject Sass into a CSS custom property

SCSS Examples

Open View Compiled CSS for verified Dart Sass output (matches official Sass docs samples where shown).

Example 1 — Official SassScript Values

A local variable drives width, height, and a calculated radius.

SCSS
.circle {
  $size: 100px;
  width: $size;
  height: $size;
  border-radius: $size * 0.5;
}

How It Works

  1. $size is scoped to the rule.
  2. width / height use the variable.
  3. $size * 0.5 evaluates to 50px.
  4. Matches the official Sass docs sample.

Example 2 — Official Nested Properties

Shared prefixes nest under one name, joined with a hyphen.

SCSS
.enlarge {
  font-size: 14px;
  transition: {
    property: font-size;
    duration: 4s;
    delay: 2s;
  }

  &:hover { font-size: 36px; }
}

How It Works

  1. transition: is the shared prefix.
  2. Nested keys become transition-*.
  3. &:hover is a nested style rule, not a property nest.
  4. Matches the official Sass docs sample.

Example 3 — Official Shorthand + Nested Longhands

Set a shorthand value and override sides underneath.

SCSS
.info-page {
  margin: auto {
    bottom: 10px;
    top: 2px;
  }
}

How It Works

  1. margin: auto emits the shorthand.
  2. Nested bottom / top become longhands.
  3. Useful for namespace properties like margin- and border-.
  4. Matches the official Sass docs sample.

Example 4 — Hidden Declarations (null)

A null (or empty unquoted string) value is omitted from CSS.

SCSS
.button {
  border: 1px solid black;
  border-radius: null;
}

How It Works

  1. border compiles normally.
  2. border-radius: null is dropped.
  3. Useful when a flag or variable decides optional styles.
  4. Same idea as the official “hidden declarations” section.

Example 5 — Official CSS Custom Properties

Custom property values are almost raw CSS—interpolate to inject Sass.

SCSS
$primary: #81899b;
$accent: #302e24;
$warn: #dfa612;

:root {
  --primary: #{$primary};
  --accent: #{$accent};
  --warn: #{$warn};

  // Looks like Sass, but passed through as CSS text:
  --consumed-by-js: $primary;
}

How It Works

  1. #{$primary} injects the Sass value.
  2. Without #{}, $primary stays literal text.
  3. Quoted strings may need meta.inspect().
  4. Matches the official Sass docs sample.

Edge Cases & Pitfalls

Most declaration bugs are custom properties without interpolation, or confusing property nesting with selector nesting.

--var

Custom props ignore bare SassScript

Always wrap injected values in #{ }. See interpolation.

nest

Property nest ≠ selector nest

font: { size: ... } builds a property name. &:hover nests a style rule.

null

null hides the whole declaration

Useful for optional styles; do not confuse with the CSS keyword initial.

quotes

Interpolation strips string quotes

For custom properties, use meta.inspect() when quotes must survive.

Sass Support

Property declarations are core Sass on Dart Sass.

FeatureStatus
SassScript valuesSupported
Nested property namesSupported
Interpolated property namesSupported
Hidden null declarationsSupported
Custom properties (raw + #{ })Supported on modern Dart Sass

Compile with the Dart Sass CLI.

Key Takeaways

  • Values can be any SassScript expression.
  • Nest shared prefixes like transition- and font-.
  • null hides a declaration from the CSS output.
  • --custom: use #{ } to inject Sass values.

One line: declarations are CSS properties with Sass superpowers—expressions, nested names, and careful custom-property injection.

Compile Notes

Practical checklist:

checklist.txt
1. Use variables / math in declaration values
2. Nest shared prefixes (font-, margin-, transition-)
3. Interpolate dynamic property names with #{}
4. Pass null to omit optional declarations
5. For --custom properties, inject Sass only via #{}

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.
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.

Next: Sass Parent Selector

Use & to attach states and suffixes to the outer selector.

Parent selector →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful