Is there a way to turn the underline on and off for a matInput within a mat-form-field using CSS or TypeScript?
I came across this post which demonstrates that the underline can be removed with CSS like this:
::ng-deep .mat-form-field-underline {
display: none;
}
However, I am uncertain if it is possible to toggle this through an [ngClass]
directive.
The post also mentions that it can be achieved programmatically, but I am not sure if this change can be reversed. Additionally, I am using material design with the prefix mat
instead of md
...
@ViewChild('input') input: MdInputDirective;
ngOnInit(){
this.input.underlineRef.nativeElement.className = null;
}
You can view my example on StackBlitz.