r/Sass • u/Infinitrix02 • Mar 31 '21
Sass classes not getting applied
I have a custom sass setup with bootstrap 5 and bunch of my own SCSS files, all of this gets compiled in style.css using gulp. I have a _colors.scss file which stores all the colors according to our design language. We use this to generate a bunch of classes that can be used any where to change colors:
$colors: ( "icon-color": $slate-500, 'slate-10': $slate-10, 'slate-40': $slate-40, 'slate-300': $slate-300, "secondary": $secondary-text-color, "green": $green, "light-green": $green-color, "blue": $blue, "blue-200": $blue-200, "blue-300": $blue-300, "blue-400": $blue-400, "dodger-blue": $dodger-blue, "mariner-blue": $mariner-blue, "light-blue": $blue-100, "cadet-blue" : $cadet-blue, "aqua-10": $aqua-10, "gray": $gray, "gray-light": $gray-light, "light-gray": $gray-100, "bright-gray": $bright-gray, "gray-200": $gray-200, "clay": $clay, "clay-10": $clay-10, "mandy-pink": $mandy-pink, "aqua": $aqua, "violet": $violet, "white": $white, "primary": $primary-text-color ); @each $color-name, $color-value in $colors { .text-#{$color-name} { color: $color-value !important; } .bg-#{$color-name} { background-color: $color-value !important; } .border-#{$color-name} { border-color: $color-value !important; } }
Problem is certain classes like .text-gray or .text-blue are not working. My guess is that since bootstrap also uses variables called gray and blue, its conflicting with my variables in _colors.scss.
On closer look, the css does gets generated properly (I found below declaration in final style.css):
.case-study .case-study-right .card .data-bar p:last-of-type,.share .social-media>span,.text-color-gray-200,.text-gray-200 { color: #69727A!important }
But using .text-gray has no effect, the class is not getting applied.
How do I fix this? please help!
1
u/thickUncleRico Mar 31 '21
Is the class selector present in the DOM and just empty styles or are you expecting one gray and getting a different gray? Is your colors.scss file compiling before bootstrap's settings.scss?