Interpolation embeds a SassScript expression into a chunk of CSS. Wrap the expression in #{ } inside selectors, property names, URLs, custom properties, strings, and more.
Official sample idea.
.icon-#{$name} and url("/icons/#{$name}.svg") inject the value of $name into CSS text.
Not for ordinary values.
Write color: $accent—not color: #{$accent}. Interpolation is for CSS syntax, not plain SassScript values.
Avoid #{$width}px.
Interpolation returns an unquoted string and skips unit safeguards. Prefer $width * 1px (or declare $width with units).
Syntax
Syntax
SCSS
// Inject into CSS text:
.icon-#{$name} { ... }
#{$side}: 0;
url("/icons/#{$name}.svg");
--brand: #{$accent};
// Ordinary property values — no interpolation needed:
color: $accent;
// In SassScript, #{ } always returns an unquoted string:
$name: inline-#{unique-id()};
Pattern: build a CSS identifier / string / at-rule fragment → wrap the dynamic part in #{ } → compile to plain CSS.
One line: use #{expression} to embed SassScript into CSS identifiers and strings—not into ordinary property values.
Practice
Compile Notes
Practical checklist:
checklist.txt
1. Need a dynamic selector / property name / URL? Use #{ }
2. Need a normal property value? Use $var directly
3. Need a custom property value? Use #{$var}
4. Need units? Prefer math ($n * 1px), not #{$n}px
5. Need only to unquote? Prefer string.unquote()
Frequently Asked Questions
Interpolation embeds a SassScript expression into CSS by wrapping it in #{ }. Example: .icon-#{$name} becomes .icon-mail when $name is mail.
Almost anywhere CSS text is written: selectors, property names, custom property values, CSS at-rules, @extend, plain CSS @import, quoted or unquoted strings, special functions, plain CSS function names, and loud comments.
No. Instead of color: #{$accent}, write color: $accent. Interpolation is for injecting values into identifiers, strings, and other CSS syntax—not ordinary SassScript values.
Interpolation returns an unquoted string, so you lose Sass math and unit checks. Prefer $width * 1px, or declare $width with px from the start.
Yes. #{"string"} injects string without quotes. Prefer string.unquote($string) when your goal is only to unquote.
In SassScript, interpolation always returns an unquoted string. That is useful for dynamic names and slash-separated values, but not for further math.