Description
Feature Description
Add an input property to MatLabel that changes the use of <label>
into a basic div element without linking it to a control. Perhaps it could be implemented as:
<mat-form-field>
<mat-label [displayOnly]="true">The label</mat-label>
<non-labelable-form-control/>
</mat-form-field>
Use Case
When using form fields with standard 'labelable' form elements such as <input>
and <select>
and using a <mat-label>
to label the field, the HTML specification for the <label for="x">
works very nicely. However, there are times when non-standard form elements are desirable to use, such as <mat-select>
with html formatted options, or other custom form fields that you might build yourself. In these cases when you use the <mat-label>
element, the resulting <label for="x">
generates a page error with the violation:
Incorrect use of <label for=FORM_ELEMENT>

You can leave out <mat-label>
to work around this, however, it is a better user experience to have the floating label and to also have these form fields match the appearance and behaviour of the other fields in a form.