Change color of matInput

mat input type color
mat-form-field css
mat-form-field appearance=outline not working
mat-button color change
how to change color of button in angular
angular material tabs change color
mat input change event

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">

Stackblitz example

Image example

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

Changing border color in mat-form-field, Border */ .mat-form-field-appearance-outline .mat-form-field-outline { color: white; } /* Font color */ input.mat-input-element { color: white; }. Though, there is still a  Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Learn more Changing border color in mat-form-field

There are two classes, .mat-form-field-label for the text label and .mat-form-field-underline for the underline. Override these two classes by giving them desired styles.

Here is a working link


how to color text input in Angular material, For changing the color of place-holder(in this case 'input') you can ::ng-deep input.mat-input-element { color: #484a4c; } /* Change label color  .dummy-input-field .mat-input-placeholder { color: red; } Similarly, if you'd like to dynamically change color if the field is focused: .dummy-input-field.mat-focused .mat-input-placeholder { color: red; }

If you put the form inside a div and give it a class then use ::ng-deep className {...} you wont override all the "mat-form-field" in the application.

::ng-deep .create-account-form {
  .mat-focused .mat-form-field-ripple {
    /*change color of underline when focused*/
    background-color: @color-blue !important;
  .mat-focused .mat-form-field-label {
    /*change color of label when focused*/
    color: @color-blue !important;
<form class="create-account-form">
      <mat-form-field class="input-size">
        <input type="email" mdInput formControlName="email" placeholder="Email" required matInput>

Overriding Angular Material Component Colors, For cases where the default colors do not provide a complete solution. It's challenging to find resources that extend or modify the component styles and colors of the Angular Material Design { }. <input matInput> and <textarea matInput> are used inside <mat-form-field>. It applies common underline, floating label and hint messages etc. <mat-form-field> is used with <input matInput> as given below. 1. Using <mat-label>

If you are using material theming you can use accent or primary, just add color property in mat-form-field:

<mat-form-field class="example-full-width" color="accent">
   <input matInput placeholder="Favorite food" value="Sushi">

Change color of matInput - angular - html, 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  <mat-form-field> has a color property which can be set to primary, accent, or warn. This will set the color of the form field underline and floating label based on the theme colors of your app. <mat-form-field> inherits its font-size from its parent element. This can be overridden to an explicit size using CSS.

Feature Request: matFormField appearance="fill" has no way to , in my project because the background color of the input is too hard to <mat-​form-field appearance="fill> <input matInput name="name"  Angular Material 7 - Input - The <mat-input>, an Angular Directive, is used for and elements to work under <mat-form-field>.

How to change the color of my mdInput? · Issue #3449 · angular , Well I'm using mdInput and I don't know how to change the color of the input. Look this picture: How to put a blue, red, yellow color? Do I need  Step 2) Add CSS: In most browsers, the placeholder text is grey. To change this, style the placeholder with the non-standard ::placeholder selector. Note that Firefox adds a lower opacity to the placeholder, so we use opacity: 1 to fix this.

Input, matInput is a directive that allows native <input> and <textarea> elements to work color; date; datetime-local; email; month; number; password; search; tel; text input becomes autofilled and changing the appearance of the autofilled state. Setting the Default Appearance. In the first step, we were setting form field appearance to individual form field components. This can be a lot of work, for instance, if you wanted to switch from one appearance to another for all your material form fields.

  • You have to define your own Material theme, and then set the "color" to that theme.
  • ::ng-deep and /deep/ are deprecated by the way.
  • Thanks. Using --> ::ng-deep.mat-form-field-ripple { /*change color of underline when focused*/ background-color: green !important;; } works.
  • Great,you should also try with material custom themes.Here is one example from my prevous answer:…
  • To new developers please note that this way is now deprecated and should no longer be used. If you still need a solution to change css on angular components child elements then you can still do them in your main styles.scss
  • @Reactgular i thought is not deprecated yet They have been saying they are going to deprecated since like 3 versions ago.