How do I change md-input-container placeholder color using css in angular material?

digit picture digit · Dec 18, 2016 · Viewed 48.6k times · Source

How do I change md-input-container placeholder color using css in Angular Material? As screenshot below I have phone no. and password textfield. Phone no. textfield has Phone No. and password has Password placeholder name.

enter image description here

Answer

Wenakari picture Wenakari · Mar 8, 2018

in the last version of angular you can remove the placeholder in the input and add a mat-placeholder in the mat-form-field and custom the css with a class

html :

<mat-form-field>
    <input matInput type="text">
    <mat-placeholder class="placeholder">Search</mat-placeholder>
</mat-form-field>

css:

.mat-focused .placeholder {
    color: #00D318;
}