I am using Angular Material 8.2.3 in my project and I am trying to change the selected value color for Mat-Select component(ie drop down menu) as below.
In chrome inspector I can see the font color is defined by class .mat-select-value
However when I try to change the color using class selectors nothing happens.
Is there a way to change the selected value color? I have other menu drop downs on the page so it has to be confined to this component. Many thanks in advance.
My code below.
HTML
<mat-select class="custom-color" [(ngModel)]="value">
<mat-option>
Yes
</mat-option>
<mat-option>
No
</mat-option>
</mat-select>
CSS
Attempt 1:
.custom-color.mat-select-value{
color: green !important;
}
Attempt 2:
.custom-color > .mat-select-value{
color: green !important;
}


You should add a class in the select (like you already did).
After that, you need to get the selector of how deep you want to go (if there's div inside div inside div...)
If the class you set is in the same html component as the
mat-select-valueclass, then you are ok doing.custom-color.mat-select-value.However, angular material styles works in a way you can't access it's class easy (if you don't use
ng-deep).To style the component you must do the following:
Create a mixin in your scss component:
After that, declare your @mixin in your main scss file (i.e. styles.scss)
Try it out.
Material theme guide in case you need:
https://material.angular.io/guide/theming