I have an angular 7 project with Angular Material. I am using one of the standard themes. I am trying to control the progress bar component to be able to set it to change colour from red to green depending on it's value.
The only way I can see to control it's colour is to pass in one of primary
/ accent
/ warn
.
However, I don't want to interfere with my main theme. I thought maybe I could approach this by creating a custom theme which extends the one I am currently using, e.g. :
@import '~@angular/material/theming';
@include mat-core();
$candy-app-primary: mat-palette($mat-indigo);
$candy-app-accent: mat-palette($mat-pink, A200, A100, A400);
$candy-app-warn: mat-palette($mat-red);
$candy-app-green: mat-palette($mat-green); // MY CUSTOM NAMED THEME ATTRIBUTE
$candy-app-red: mat-palette($mat-red); // MY CUSTOM NAMED THEME ATTRIBUTE
$candy-app-theme: mat-light-theme($candy-app-primary, $candy-app-accent, $candy-app-warn);
// that you are using.
@include angular-material-theme($candy-app-theme);
and then controlling my component like this:
<mat-progress-bar mode="determinate" value="40" color="green"></mat-progress-bar>
I appreciate that the progress bar doesn't seem to support any other colour aliases, so not sure that I can make this approach work> Any ideas for how I could achieve this result. i.e. I want to change the colour of the progress bar without disrupting the rest of my app which relies on the existing theme.