I am now trying for hours. I use Material2 and simply want to change the color of the progress-bar. I know there are those themes (primary/accent/warn) but I want to have a cutom color (green) for my progressbar.
I already tried the wierdest css-combinations.. but with no effort. Maybe someone had the same problem?
Since nobody mentioned so far...
He's how I solved it.
@Meet Dave is right about his approach. But you should use
encapsulation: ViewEncapsulation.None
(disables css modules)Something like this:
Component
Sass (in my case)
View
Update:
Avoid using deep, TL;DR: Deep is technically invalid (like, deeprecated :p)
For more info refer: The use of /deep/ and >>> in Angular 2
Now, to change the color of mat-progress bar, Here is how I got it working,
Head over to your styles.scss file (or the main css/scss file in your project)
Add this class -->
Your mat-progress should use the above class, like -->
Angular 7 and Material 7.1.1
I can suggest to change one of the premade primary/warn/accent colors to your custom color.
In your
styles.scss
(if your style file is css you will have to change it to support scss):You can override only progress bar backgroud-color through this method added custom class then apply css by combination of tag and class like-
<mat-progress-bar class="my-color" mode="determinate" value="40"></mat-progress-bar>
Change into style.css
mat-progress-bar.my-color .mat-progress-bar-fill::after { background-color: green; }
Angular 8 solution:
for me it was putting my styling in a top level
.scss
file. Also had to select in.scss
as follows:html:
styles.scss: