How to hide/delete underline input Angular Material?

前端 未结 10 1067
伪装坚强ぢ
伪装坚强ぢ 2020-12-14 06:24

I have input element in Angular Material:




         


        
相关标签:
10条回答
  • 2020-12-14 06:44

    you can set your appearance to none in mat-form-field tag like this :

    <mat-form-field class="header-search-form-field" appearance="none">
        <mat-label>search</mat-label>
        <input matInput placeholder="add product/>
    </mat-form-field>
    
    0 讨论(0)
  • 2020-12-14 06:44

    The other answers didn't work for me, but this did:

    md-input-container input {
            border: none;
    }
    
    0 讨论(0)
  • 2020-12-14 06:47

    This worked for me:

    ::ng-deep .mat-form-field-underline {
        display: none;
    }
    

    Add it to the component's scss or css

    0 讨论(0)
  • 2020-12-14 06:54
    This worked for me
    
    .mat-form-field-appearance-legacy .mat-form-field-underline {
        height: 0 !important;
    }
    
    0 讨论(0)
  • 2020-12-14 06:56

    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.

    0 讨论(0)
  • 2020-12-14 06:56

    ::ng-deep .mat-form-field-underline {
      display: none;
    }

    the above code will remove the default black underline

    ::ng-deep .mat-form-field-ripple {
      display: none;
    }

    this will remove the on focus ripple effect

    0 讨论(0)
提交回复
热议问题