Text Fields
The mdcTextField
directive provides various types of text-fields.
A text-field is composed of a label, input element, line, helper text, and possibly a leading or trailing icon.
API
Directive: MdcTextFieldInputDirective
Selector: input[mdcTextFieldInput] textarea[mdcTextFieldInput]
Directive for the native input of an mdcTextField
.
Property | Description |
---|---|
@Input()
id
string
|
Mirrors the |
@Input()
disabled
boolean
|
If set to a value other than false, the text-field will be in disabled state. |
Directive: MdcTextFieldIconDirective
Selector: [mdcTextFieldIcon]
Directive for an optional leading or trailing icon on the text-field (see
MdcTextFieldDirective
). An icon before the mdcTextFieldInput
will be styled
as a leading icon. An icon after the mdcTextFieldInput
will be styles as a
trailing icon.
Property | Description |
---|---|
@Output()
interact
EventEmitter<void>
|
Event emitted for icon interactions (a click or an 'enter' keypress). When this output is assigned,
the icon will also set the |
@Input()
tabindex
|
The |
@Input()
role
|
The |
Directive: MdcTextFieldHelperLineDirective
Selector: [mdcTextFieldHelperLine]
This directive wraps an optional mdcTextFieldHelperText
. It should be the next sibling of the
associated mdcTextField
if used. See mdcTextFieldHelperText
for more info.
Directive: MdcTextFieldHelperTextDirective
Selector:
[mdcTextFieldHelperText]
Exported as:
mdcHelperText
Directive for an optional helper-text to show supplemental information or validation
messages for an mdcTextField
. This directive should be wrapped inside an
mdcTextFieldHelperLine
that comes directly after the mdcTextField
it belongs to.
Additionally, you must export it as an mdcHelperText
, and
assign the exported object to the helperText
property of the
mdcHelperText
. See the examples for hints on how to do this.
The mdcTextFieldInput
of the textfield will get aria-controls
and aria-describedby
accessibility attributes that point to the id
of this helpertext element. If no id
has
been assigned, a unique id
attribute will automatically be assigned. If the id
attribute
is changed, the aria attributes on the mdcTextFieldInput
will be updated accordingly.
Property | Description |
---|---|
@Input()
validation
boolean
|
If set to a value other than false, the helper text is treated as a validation message, and only shown when the input is invalid. |
@Input()
persistent
boolean
|
If set to a value other than false, the helper text is always visible.
Otherwise the helper text will only be shown when the input has focus
(or if |
Directive: MdcTextFieldDirective
Selector: [mdcTextField]
Material design text-field. Text fields can be filled or outlined.
Filled text-fields should have the following child directives:
mdcTextFieldIcon
(optional leading icon)mdcTextFieldInput
(required, the native input)mdcTextFieldIcon
(optional trailing icon)mdcFloatingLabel
(optional floating label)
Outlined text-fields should have the following child directives:
mdcTextFieldIcon
(optional leading icon)mdcTextFieldInput
(required, the native input)mdcTextFieldIcon
(optional trailing icon)mdcNotchedOutline
(the outline, which can also contain an optionalmdcFloatingLabel
)
Addditionally the text-field can be followed by an mdcTextFieldHelperLine
containing an
mdcHelperText
.
Property | Description |
---|---|
@Input()
valid
boolean
|
The For most use cases messing with this input is not be needed.
When the input/textarea is an ngControl, the mdcTextField is already aware of that,
and is already using the 'valid' property of that control.
However, in some specific cases, binding to |
@Input()
helperText
MdcTextFieldHelperTextDirective | null
|
Assign an |