Skip to main content

Textarea

<gstock-textarea> | GstockTextarea

API

Properties

Name Description Reflects Type Default
defaultValue The default value of the form control. Primarily used for resetting the form control. string ''
autocapitalize Controls whether and how text input is automatically capitalized as it is entered by the user. 'off' | 'none' | 'on' | 'sentences' | 'words' | 'characters' -
autocomplete Specifies what permission the browser has to provide assistance in filling out form field values. Refer to this page on MDN for available values. string -
autocorrect Indicates whether the browser’s autocorrect feature is on or off. string -
autofocus Indicates that the input should receive focus on page load. boolean -
disabled Disables the textarea. Reflects boolean false
enterkeyhint Used to customize the label or icon of the Enter key on virtual keyboards. 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send' -
form By default, form controls are associated with the nearest containing <form> element. This attribute allows you to place the form control outside of a form and associate it with the form that has this id. The form must be in the same document or shadow root for this to work. Reflects string ''
helpText
help-text
The textarea’s help text. If you need to display HTML, use the help-text slot instead. string ''
inputmode Tells the browser what type of data will be entered by the user, allowing it to display the appropriate virtual keyboard on supportive devices. 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url' -
label The textarea’s label. If you need to display HTML, use the label slot instead. string ''
maxlength The maximum length of input that will be considered valid. Reflects number -
name The name of the textarea, submitted as a name/value pair with form data. string ''
placeholder Placeholder text to show as a hint when the input is empty. string ''
readonly Makes the textarea readonly. Reflects boolean false
required Makes the textarea a required field. Reflects boolean false
resize Controls how the textarea can be resized. 'none' | 'vertical' | 'auto' 'vertical'
rows The number of rows to display by default. number 4
size The textarea’s size. Reflects 'small' | 'medium' | 'large' 'medium'
spellcheck Enables spell checking on the textarea. boolean true
title Global attribute contains text representing advisory information related to the element it belongs to. string ''
validity Gets the validity state object - -
validationMessage Gets the validation message - -
updateComplete

A read-only promise that resolves when the component has finished updating.

Learn more about attributes and properties .

Events

Name React Event Description Event Detail
gstock-blur-event onGstockBlurEvent Emitted when the control loses focus. -
gstock-change-event onGstockChangeEvent Emitted when an alteration to the control’s value is committed by the user. -
gstock-focus-event onGstockFocusEvent Emitted when the control gains focus. -
gstock-input-event onGstockInputEvent Emitted when the control receives input. -
gstock-invalid-event onGstockInvalidEvent Emitted when the form control has been checked for validity and its constraints aren’t satisfied. -

Learn more about events .

Slots

Name Description
label The textarea’s label. Alternatively, you can use the label attribute.
help-text Text that describes how to use the input. Alternatively, you can use the help-text attribute.

Learn more about slots .

Methods

Name Description
focus(
options: FocusOptions
)
Sets focus on the textarea.
blur( ) Removes focus from the textarea.
select( ) Selects all the text in the textarea.
scrollPosition(
position: { top?: number; left?: number; }
)
Gets or sets the textarea’s scroll position.
setSelectionRange(
selectionStart: number ,
selectionEnd: number ,
selectionDirection: 'forward' | 'backward' | 'none'
)
Sets the start and end positions of the text selection (0-based).
setRangeText(
replacement: string ,
start: number ,
end: number ,
selectMode: 'select' | 'start' | 'end' | 'preserve'
)
Replaces a range of text with a new string.
checkValidity( ) Checks for validity but does not show a validation message. Returns true when valid and false when invalid.
getForm( ) Gets the associated form, if one exists.
reportValidity( ) Checks for validity and shows the browser’s validation message if the control is invalid.
setCustomValidity(
message: string
)
Sets a custom validation message. Pass an empty string to restore validity.

Learn more about methods .

CSS Parts

Name Description
form-control The form control that wraps the label, input, and help text.
form-control-label The label’s wrapper.
form-control-input The input’s wrapper.
form-control-help-text The help text’s wrapper.
base The component’s base wrapper.
textarea The internal <textarea> control.

Learn more about CSS parts .