Sass Interpolation

You are Here:

Sass Interpolation

Interpolation is used to embed the result of a SassScript expression into a chunk of CSS by wrapping an expression in #{}.

Example

SASS TO CSS CONVERTER
@mixin icon($name) { .icon-#{$name} { background-image: url("/icons/#{$name}.svg"); } } @include icon("bicycle"); @include icon("bike");

Syntax

#{expression}

Sass Interpolation with Dynamic CSS Property

Interpolation can be used to create a dynamic CSS property.

Example

SASS TO CSS CONVERTER
@mixin corner-icon($name, $top-or-bottom, $left-or-right) { .icon-#{$name} { background-image: url("/icons/#{$name}.svg"); position: absolute; #{$top-or-bottom}: 0; #{$left-or-right}: 0; } } @include corner-icon("cycle", bottom, right);

Reminder

Hi Developers, we almost covered 99.1% of Sass Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in Sass.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author