Description
Bug, feature request, or proposal:
Proposal / feature request.
What is the expected behavior?
The official Material guidelines state that text input fields which are prefixed with an icon (referred to as "icon signifiers" in the spec) should display the icon as floating to the left of the text field, centered vertically.
Note that the specified behavior for icons is different from the specified behavior for text-only prefixes. Text prefixes are covered by another part of the Material guidelines:
These guidelines also show that the label should extend to the left above a text prefix. Text prefixes should be treated differently than icon prefixes.
What is the current behavior?
Currently, an icon given matPrefix
will be displayed above the underline, which extends to the left below the prefix.
The icon is also not vertically centered with the input itself. In the lower example, a span
element containing a text-only prefix shifts the label to the right which also conflicts with the Material guidelines.
What are the steps to reproduce?
What is the use-case or motivation for changing an existing behavior?
Conforming to the Material guidelines will provide a more faithful implementation and make apps built using Angular Material more visually consistent with Material apps on other platforms, such as Android.
Inputs with icons and prefixes are very common, so this affects many apps using Angular Material. The desired behavior can probably be replicated using custom CSS, but this might require penetrating the shadow DOM of mat-form-field
which would be messy and this behavior shouldn't require that much effort.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
All of them.
Is there anything else we should know?
AngularJS Material correctly implements icon signifiers, but does not seem to support text prefixes.
Though it was built with React (boo), a good example of Material-looking text fields with icon signifiers is Patreon's Sign Up page.
I would propose keeping the existing matPrefix
directive for text-only prefixes, correcting the label position to start at the left side of the prefix instead of to the right, and perhaps adding a new directive such as matIconPrefix
or something similar for icon signifiers.