diff --git a/src/lib/form-field/form-field.md b/src/lib/form-field/form-field.md index 4440f5f9fed..0bedd24cb09 100644 --- a/src/lib/form-field/form-field.md +++ b/src/lib/form-field/form-field.md @@ -13,6 +13,31 @@ The following Angular Material components are designed to work inside a ` +### Form field appearance variants +The `mat-form-field` supports 4 different appearance variants which can be set via the `appearance` +input. The `legacy` appearance is the default style that the `mat-form-field` has traditionally had. +It shows the input box with an underline underneath it. The `standard` appearance is a slightly +updated version of the `legacy` appearance that has spacing that is more consistent with the `fill` +and `outline` appearances. The `fill` appearance displays the form field with a filled background +box in addition to the underline. Finally the `outline` appearance shows the form field with a +border all the way around, not just an underline. + +There are a couple differences to be aware of between the `legacy` appearance and the newer +`standard`, `fill`, and `outline` appearances. The `matPrefix` and `matSuffix` elements are center +aligned by default for the newer appearances. The Material Design spec shows this as being the +standard way to align prefix and suffix icons in the newer appearance variants. We do not recommend +using text prefix and suffixes in the new variants because the label and input do not have the same +alignment. It is therefore impossible to align the prefix or suffix in a way that looks good when +compared with both the label and input text. + +The second important difference is that the `standard`, `fill`, and `outline` appearances do not +promote placeholders to labels. For the `legacy` appearance specifying +`` will result in a floating label being added to the +`mat-form-field`. For the newer variants it will just add a normal placeholder to the input. If you +want a floating label, add a `` to the `mat-form-filed`. + + + ### Floating label The floating label is a text label displayed on top of the form field control when diff --git a/src/lib/input/input.md b/src/lib/input/input.md index afb5a8c291b..917a66e0994 100644 --- a/src/lib/input/input.md +++ b/src/lib/input/input.md @@ -17,6 +17,7 @@ also contains an `` element. The following [input types](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input) can be used with `matInput`: +* color * date * datetime-local * email diff --git a/src/material-examples/form-field-appearance/form-field-appearance-example.css b/src/material-examples/form-field-appearance/form-field-appearance-example.css new file mode 100644 index 00000000000..7432308753e --- /dev/null +++ b/src/material-examples/form-field-appearance/form-field-appearance-example.css @@ -0,0 +1 @@ +/** No CSS for this example */ diff --git a/src/material-examples/form-field-appearance/form-field-appearance-example.html b/src/material-examples/form-field-appearance/form-field-appearance-example.html new file mode 100644 index 00000000000..4ccce921bf3 --- /dev/null +++ b/src/material-examples/form-field-appearance/form-field-appearance-example.html @@ -0,0 +1,32 @@ +

+ + Legacy form field + + sentiment_very_satisfied + Hint + +

+

+ + Standard form field + + sentiment_very_satisfied + Hint + +

+

+ + Fill form field + + sentiment_very_satisfied + Hint + +

+

+ + Outline form field + + sentiment_very_satisfied + Hint + +

diff --git a/src/material-examples/form-field-appearance/form-field-appearance-example.ts b/src/material-examples/form-field-appearance/form-field-appearance-example.ts new file mode 100644 index 00000000000..77f124fcd90 --- /dev/null +++ b/src/material-examples/form-field-appearance/form-field-appearance-example.ts @@ -0,0 +1,9 @@ +import {Component} from '@angular/core'; + +/** @title Form field appearance variants */ +@Component({ + selector: 'form-field-appearance-example', + templateUrl: 'form-field-appearance-example.html', + styleUrls: ['form-field-appearance-example.css'] +}) +export class FormFieldAppearanceExample {}