import {MatFormFieldModule} from '@angular/material/form-field';
MatFormField
Container for form controls that applies Material Design styling and behavior.
Selector: mat-form-field
Exported as: matFormFieldName | Description |
---|---|
@Input()
|
The form field appearance style. |
@Input()
|
Theme color of the form field. This API is supported in M2 themes only, it has no effect in M3 themes. For color customization in M3, see https://material.angular.dev/components/form-field/styling. For information on applying color variants in M3, see https://material.angular.dev/guide/material-2-theming#optional-add-backwards-compatibility-styles-for-color-variants |
@Input()
|
Whether the label should always float or float as the user types. |
@Input()
|
Whether the required marker should be hidden. |
@Input()
|
Text for the form field hint. |
@Input()
|
Whether the form field should reserve space for one line of hint/error text (default) or to have the spacing grow from 0px as needed based on the size of the hint/error content. Note that when using dynamic sizing, layout shifts will occur when hint/error text changes. |
|
Gets the id of the label element. If no label is present, returns |
getConnectedOverlayOrigin | |
---|---|
Gets an ElementRef for the element that a overlay attached to the form field should be positioned relative to. |
|
Returns | |
ElementRef
|
|
MatFormFieldControl
An interface which allows a control to work inside of a MatFormField
.
Name | Description |
---|---|
|
Whether the input is currently in an autofilled state. If property is not present on the control it is assumed to be false. |
|
An optional name for the control type that can be used to distinguish |
|
Gets the list of element IDs that currently describe this control. |
|
Whether to automatically assign the ID of the form field as the |
|
Whether the control is disabled. |
|
Whether the control is empty. |
|
Whether the control is in an error state. |
|
Whether the control is focused. |
|
The element ID for this control. |
|
Gets the AbstractControlDirective for this control. |
|
The placeholder for this control. |
|
Whether the control is required. |
|
Whether the |
|
Stream that emits whenever the state of the control changes such that the parent |
|
Value of |
|
The value of the control. |
onContainerClick | |
---|---|
Handles a click on the control's container. |
|
Parameters | |
event MouseEvent
|
|
setDescribedByIds | |
---|---|
Sets the list of element IDs that currently describe this control. |
|
Parameters | |
ids string[]
|
|
MatFormFieldDefaultOptions
Represents the default options for the form field that can be configured
using the MAT_FORM_FIELD_DEFAULT_OPTIONS
injection token.
Name | Description |
---|---|
|
Default form field appearance style. |
|
Default theme color of the form field. This API is supported in M2 themes only, it has no effect in M3 themes. For color customization in M3, see https://material.angular.dev/components/form-field/styling. For information on applying color variants in M3, see https://material.angular.dev/guide/material-2-theming#optional-add-backwards-compatibility-styles-for-color-variants |
|
Whether the label for form fields should by default float |
|
Whether the required marker should be hidden by default. |
|
Whether the form field should reserve space for one line by default. |
FloatLabelType
Type for the available floatLabel values.
type FloatLabelType = 'always' | 'auto';
MatFormFieldAppearance
Possible appearance styles for the form field.
type MatFormFieldAppearance = 'fill' | 'outline';
SubscriptSizing
Behaviors for how the subscript height is set.
type SubscriptSizing = 'fixed' | 'dynamic';
MAT_FORM_FIELD
Injection token that can be used to inject an instances of MatFormField
. It serves
as alternative token to the actual MatFormField
class which would cause unnecessary
retention of the MatFormField
class and its component metadata.
const MAT_FORM_FIELD: InjectionToken;
MAT_FORM_FIELD_DEFAULT_OPTIONS
Injection token that can be used to configure the default options for all form field within an app.
const MAT_FORM_FIELD_DEFAULT_OPTIONS: InjectionToken;