How to hide/delete underline input Angular Material?

Daniel picture Daniel · Aug 8, 2017 · Viewed 50.3k times · Source

I have input element in Angular Material:

<md-input-container>
<input type="text" mdInput placeholder="">
</md-input-container>

When input has focus it displays underline. How to hide or remove that?

Seem I need to set null for underlineRef?

Answer

jurl picture jurl · Mar 28, 2019

I was playing a bit with the appearance property of mat-form-field and found that if you put a "none" value (or any other unsupported value), you will get clear input.

The code:

  <mat-form-field appearance="none">
    <mat-label>"None" form field</mat-label>
    <input matInput placeholder="Placeholder">
  </mat-form-field>

StackBlitz demo (edited from the official angular demo).

The original example can be found here: Form field appearance variants.

I admit, this is a little bit of a hack.