I have input element in Angular Material:
Update:
Import MdInputDirective
import {MdInputDirective} from '@angular/material';
In compoent do following:
@ViewChild('input') input: MdInputDirective;
ngOnInit(){
this.input.underlineRef.nativeElement.className = null;
}
In html, add the #input
reference:
<md-input-container #input>
<input mdInput placeholder="Last 4 SSN">
</md-input-container>
Plunker demo
Original:
Try css:
::ng-deep .mat-input-underline {
display: none;
}
demo
just set appearance="none"
inside the tag
<mat-form-field style="width:40px" appearance="none"> </mat-form-field>
If you are using mat-form-field
instead of md-input-container
and google-landed here, here are your two options.
mat-form-field
and use your own styles.For me it worked without ::ng-deep
. Using Angular 6.1.10 as follows:
<form>
<mat-form-field class="no-line">
<input type="text"
matInput
field="label"
[matAutocomplete]="auto"
[formControl]="formControl"/>
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let food of foods" [value]="food.value">
{{ food.label}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</form>
.no-line .mat-form-field-underline {
display: none;
}