How do I change matInput to a custom color. I want to change the placeholder and underline color.
I have read through most of the posts and could not find a solution to change the underline.
<mat-form-field class="example-full-width">
<input matInput placeholder="Favorite food" value="Sushi">
</mat-form-field>
Stackblitz example
Image example
Using --> ::ng-deep. mat-form-field-ripple { /*change color of underline when focused*/ background-color: green ! important;; } works.
Go to Node_modules → @angular → material → prebuilt-themes → indigo-pink. css → Find mat-form-filed-appearance-outline, and then change your color.
You can use plain css
::ng-deep .mat-focused .mat-form-field-label {
/*change color of label*/
color: green !important;
}
::ng-deep.mat-form-field-underline {
/*change color of underline*/
background-color: green !important;
}
::ng-deep.mat-form-field-ripple {
/*change color of underline when focused*/
background-color: green !important;;
}
or create custom theme to apply on.Here is article,how to create custom themes
https://alligator.io/angular/angular-material-custom-theme/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With