diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 246d1b5a4fe6..55bda6cb2fd3 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -41,6 +41,7 @@
/src/lib/core/line/** @jelbourn
/src/lib/core/option/** @kara @crisbeto
/src/lib/core/placeholder/** @kara @mmalerba
+/src/lib/core/label/** @kara @mmalerba
/src/lib/core/ripple/** @devversion
/src/lib/core/selection/** @tinayuangao @jelbourn
/src/lib/core/selection/pseudo*/** @crisbeto @jelbourn
diff --git a/guides/creating-a-custom-form-field-control.md b/guides/creating-a-custom-form-field-control.md
index e421d9a28cd7..768f0e64c928 100644
--- a/guides/creating-a-custom-form-field-control.md
+++ b/guides/creating-a-custom-form-field-control.md
@@ -58,7 +58,7 @@ class MyTelInput {
tel = tel || new MyTel('', '', '');
this.parts.setValue({area: tel.area, exchange: tel.exchange, subscriber: tel.subscriber});
}
-
+
constructor(fb: FormBuilder) {
this.parts = fb.group({
'area': '',
@@ -98,7 +98,7 @@ the `MatFormFieldControl` interface, see the
#### `value`
This property allows someone to set or get the value of our control. Its type should be the same
-type we used for the type parameter when we implemented `MatFormFieldControl`. Since our component
+type we used for the type parameter when we implemented `MatFormFieldControl`. Since our component
already has a value property, we don't need to do anything for this one.
#### `stateChanges`
@@ -212,16 +212,16 @@ get empty() {
}
```
-#### `shouldPlaceholderFloat`
+#### `shouldLabelFloat`
-This property is used to indicate whether the placeholder should be in the floating position. We'll
+This property is used to indicate whether the label should be in the floating position. We'll
use the same logic as `matInput` and float the placeholder when the input is focused or non-empty.
Since the placeholder will be overlapping our control when when it's not floating, we should hide
the `–` characters when it's not floating.
```ts
@HostBinding('class.floating')
-get shouldPlaceholderFloat() {
+get shouldLabelFloat() {
return this.focused || !this.empty;
}
```
@@ -307,7 +307,7 @@ just need to apply the given IDs to our host element.
```ts
@HostBinding('attr.aria-describedby') describedBy = '';
-
+
setDescribedByIds(ids: string[]) {
this.describedBy = ids.join(' ');
}
diff --git a/src/demo-app/a11y/input/input-a11y.html b/src/demo-app/a11y/input/input-a11y.html
index 8129ee38d788..cb9d19dfb345 100644
--- a/src/demo-app/a11y/input/input-a11y.html
+++ b/src/demo-app/a11y/input/input-a11y.html
@@ -1,9 +1,9 @@
Basic input box (e.g. name field)
-
+
-
+
@@ -34,12 +34,12 @@
Input with error message (e.g. email field)
Input with prefix & suffix (e.g. currency converter)
diff --git a/src/lib/form-field/form-field.md b/src/lib/form-field/form-field.md
index 19d954a98e26..c28164137e08 100644
--- a/src/lib/form-field/form-field.md
+++ b/src/lib/form-field/form-field.md
@@ -13,35 +13,39 @@ The following Angular Material components are designed to work inside a `
-### Floating placeholder
+### Floating label
-The floating placeholder is a text label displayed on top of the form field control when
-the control does not contain any text. By default, when text is present the floating placeholder
-floats above the form field control.
+The floating label is a text label displayed on top of the form field control when
+the control does not contain any text. By default, when text is present the floating label
+floats above the form field control. The label for a form field can be defined either through a
+`mat-label` element, by setting the `placeholder` attribute on the form control or using the
+`mat-placeholder` element. If there are multiple clashing values (e.g. a `placeholder` and a
+label) the `mat-label` will take precedence and the `placeholder` will be shown only when there is
+no value.
Placeholder text can be specified using the `placeholder` property on the form field control, or
by adding a `` element inside the form field. Only one of these options should be
used, specifying both will raise an error.
If the form field control is marked with a `required` attribute, an asterisk will be appended to the
-placeholder to indicate the fact that it is a required field. If unwanted, this can be disabled by
+label to indicate the fact that it is a required field. If unwanted, this can be disabled by
setting the `hideRequiredMarker` property on ``
-The `floatPlaceholder` property of `` can be used to change this default floating
-behavior. It can set to `never` to hide the placeholder instead of float it when text is present in
-the form field control. It can be set to `always` to float the placeholder even when no text is
+The `floatLabel` property of `` can be used to change this default floating
+behavior. It can set to `never` to hide the label instead of float it when text is present in
+the form field control. It can be set to `always` to float the label even when no text is
present in the form field control. It can also be set to `auto` to restore the default behavior.
-
+
-Global default placeholder options can be specified by setting providing a value for
-`MAT_PLACEHOLDER_GLOBAL_OPTIONS` in your application's root module. Like the property, the global
+Global default label options can be specified by setting providing a value for
+`MAT_LABEL_GLOBAL_OPTIONS` in your application's root module. Like the property, the global
setting can be either `always`, `never`, or `auto`.
```ts
@NgModule({
providers: [
- {provide: MAT_PLACEHOLDER_GLOBAL_OPTIONS, useValue: {float: 'always'}}
+ {provide: MAT_LABEL_GLOBAL_OPTIONS, useValue: {float: 'always'}}
]
})
```
@@ -96,7 +100,7 @@ information on this see the guide on
### Theming
`` has a `color` property which can be set to `primary`, `accent`, or `warn`. This
-will set the color of the form field underline and floating placeholder based on the theme colors
+will set the color of the form field underline and floating label based on the theme colors
of your app.
`` inherits its `font-size` from its parent element. This can be overridden to an
@@ -112,8 +116,8 @@ mat-form-field.mat-form-field {
### Accessibility
-If a floating placeholder is specified, it will be automatically used as the label for the form
-field control. If no floating placeholder is specified, the user should label the form field control
+If a floating label is specified, it will be automatically used as the label for the form
+field control. If no floating label is specified, the user should label the form field control
themselves using `aria-label`, `aria-labelledby` or `