A multi-line plain-text field for a large amount of free-form text, for example a comment in a review or feedback form.
- Slots
-
default— The text content of the default slot sets the value of the component. -
prefix— Renders content before the input. -
suffix— Renders content after the input. -
helper-text— Renders content below the input. -
value-missing— Renders content when the required validation fails. -
too-long— Renders content when the maxlength validation fails. -
too-short— Renders content when the minlength validation fails. -
custom-error— Renders content when a custom message is set with `setCustomValidity()`. -
invalid— Renders content when the component is in invalid state (validity.valid = false).
- CSS Parts
-
container— The main wrapper that holds all main input elements of the textarea. -
input— The native textarea element. -
label— The native label element of the textarea. -
prefix— The prefix wrapper of the textarea. -
suffix— The suffix wrapper of the textarea. -
helper-text— The helper text wrapper of the textarea. -
prefixed— Added to the container when an element that is not hidden is in the prefix slot. -
suffixed— Added to the container when an element that is not hidden is in the suffix slot. -
filled— Added to the container when the textarea has a value. -
placeholder— Added to the container in the material theme when the textarea has a placeholder. -
labelled— Added to the container in the material theme when the control has a label. -
start— The wrapper of the prefix in the material theme. -
notch— The wrapper of the label in the material theme. -
filler— The outline segment between the notch and the end in the material theme. -
end— The wrapper of the suffix in the material theme.
Properties
Section titled "Properties"autocapitalize
Section titled "autocapitalize"Whether and how the browser capitalizes the text that the user enters.
autocapitalize: string autocomplete
Section titled "autocomplete"A hint for the browser on how to autofill the control. Refer to this page for additional information.
autocomplete: string inputMode
Section titled "inputMode"A hint to the browser for which virtual keyboard layout to display.
inputMode: string maxLength
Section titled "maxLength"The maximum number of characters (UTF-16 code units) that the user can enter. If this value isn't specified, the user can enter an unlimited number of characters.
maxLength: number minLength
Section titled "minLength"The minimum number of characters (UTF-16 code units) that the value must have.
minLength: number outlined
Section titled "outlined"Whether the control has an outlined appearance.
outlined: boolean resize
Section titled "resize"How the user can resize the control.
With auto, the height of the control fits its content and the resize handle is hidden.
resize: TextareaResize The number of visible text lines of the control. As in the native textarea, a value less than 1 shows 2 lines.
rows: number spellcheck
Section titled "spellcheck"Whether the browser checks the spelling of the value. As for the native attribute,
only the "false" attribute value turns the check off.
spellcheck: boolean validateOnly
Section titled "validateOnly"Whether the validation rules apply without restricting user input. The user can type past maxLength.
validateOnly: boolean How the control wraps long lines of text. With off, the lines do not wrap.
Unlike the native element, hard does not add line breaks to the submitted value.
Refer to this page on MDN
for explanation of the available values.
wrap: "off" | "hard" | "soft" Accessors
Section titled "Accessors"selectionEnd
Section titled "selectionEnd"The offset of the end of the text selection, in UTF-16 code units.
get selectionEnd(): number
Returns number
selectionStart
Section titled "selectionStart"The offset of the start of the text selection, in UTF-16 code units.
Equals selectionEnd when no text is selected.
get selectionStart(): number
Returns number
Methods
Section titled "Methods"Removes focus from the control.
blur(): void Returns void
focus
Section titled "focus"Sets focus on the control.
focus(options: FocusOptions): void Parameters
- options:
FocusOptions
Returns void
scrollTo
Section titled "scrollTo"Scrolls the text of the control to the given position.
scrollTo(options: ScrollToOptions): void Parameters
- options:
ScrollToOptions
Returns void
select
Section titled "select"Selects all text within the control.
select(): void Returns void
setRangeText
Section titled "setRangeText"Replaces the text from start to end in the control. Without start and
end, replaces the selected text.
setRangeText(replacement: string, start: number, end: number, selectMode: RangeTextSelectMode): void Parameters
- replacement:
string - start:
number - end:
number - selectMode:
RangeTextSelectMode
Returns void
setSelectionRange
Section titled "setSelectionRange"Sets the text selection range of the control.
setSelectionRange(start: number, end: number, direction: SelectionRangeDirection): void Parameters
- start:
number - end:
number - direction:
SelectionRangeDirection
Returns void
Events
Section titled "Events"onChange
Section titled "onChange"Emitted when a change to the control value is committed by the user.
onChange(args: CustomEvent<string>): void Parameters
- args:
CustomEvent<string>
Returns void
onInput
Section titled "onInput"Emitted when the control receives user input.
onInput(args: CustomEvent<string>): void Parameters
- args:
CustomEvent<string>