What is variable interpolation in Sass? Provide some examples.

Technology CommunityCategory: CSSWhat is variable interpolation in Sass? Provide some examples.
VietMX Staff asked 3 years ago

If you want to use variables inside a string, you will have to use a process called variable interpolation. To use it you will have to wrap your variables in #{}.

Consider:

$name: 'Gajendar';
$author: 'Author : $name'; // 'Author : $name'

$author: 'Author : #{$name}';
// 'Author : Gajendar'

The interpolation method could be useful in situations where the value of a variable is determined by some conditional statements.