sass variables file code example
Example 1: sass use variables from another file
//_variables.scss
$light: #f5f5f5;
$dark: ##2e3033;
//_theme.scss
@import './_variables'; //relative path to file
body {
background-color: $dark;
}
Example 2: Sass Variables
$myFont: Helvetica, sans-serif;
$myColor: red;
$myFontSize: 18px;
$myWidth: 680px;
body {
font-family: $myFont;
font-size: $myFontSize;
color: $myColor;
}
#container {
width: $myWidth;
}
Example 3: scss variables mixins
// _base.scss
$font-stack: Helvetica, sans-serif;
$primary-color: #333;
body {
font: 100% $font-stack;
color: $primary-color;
}
Example 4: scss variables mixins
// styles.scss
@use 'base';
.inverse {
background-color: base.$primary-color;
color: white;
}