When I change the font type in my form, label overlays the outline. How can i fix this?
in the following image it is shown how it should be:
When I change the font type in my form, label overlays the outline. How can i fix this?
in the following image it is shown how it should be:
Seems like after 3 years there's still no fix to this issue in Angular Material.
However, there are two workarounds:
First workaround:
mat-form-field
components (directives) with appearance
attribute set to outline
document.fonts.ready
event and run updateOutlineGap
on the MatFormField
AppModule
or SharedModule
to make it accessible everywhereimport { AfterViewInit, Directive } from '@angular/core';
import { MatFormField } from '@angular/material/form-field';
@Directive({
selector: 'mat-form-field[appearance=outline]',
})
export class UpdateOutlineGapDirective implements AfterViewInit {
constructor(private formField: MatFormField) {
}
ngAfterViewInit() {
document.fonts.ready.then(() => {
this.formField.updateOutlineGap();
});
}
}
Second workaround:
#userNameField
to your mat-form-field
element(focus)="userNameField.updateOutlineGap()"
to the input element