Components
Multiline inputs for text.
| Version: | 14.18.2 •View source•Changelog•Report issue | |
|---|---|---|
| Install: | yarn add @thumbtack/thumbprint-react | |
| Import: | import { TextArea } from '@thumbtack/thumbprint-react'; | |
TextArea is a controlled component. This means that the visible text will always match the contents of the value prop.
In this example, notice how value is stored within this.state. The onChange function will set the new value when the user enters or removes a character in the textarea.
The isDisabled prop disables the TextArea visually and functionally.
The hasError prop only changes the Text Area’s color. It should be used alongside an error message that helps users advance through the form.
valueThe current value of the textarea.
stringonChangeThe function that is called when the textarea value changes.
It receives two arguments: onChange(newValue, event).
The consumer of this component should use that data to update the value prop passed in to
this component.
(newValue: string, event: React.ChangeEvent<HTMLTextAreaElement>) => voididAdds a HTML id attribute to the textarea. This is used for linking the HTML with a
Label.
stringisDisabledVisually and functionally disable the textarea.
booleanfalseisReadOnlyAdds readonly HTML attribute, allowing users to select (but not modify) the input.
booleanfalseisRequiredAdds the required HTML attribute to the textarea.
booleanfalsehasErrorMakes the textarea border and text color red.
booleanfalseplaceholderText that appears within the textarea when there is no value.
stringnameAdds name HTML attribute to element, indicating the property name associated with the selected value.
stringmaxLengthThe maximum number of characters that a user can enter. onChange will not fire if a user
enters a character that exceeds maxLength.
numberonFocusFires when the textarea receives focus.
(event: React.FocusEvent<HTMLTextAreaElement>) => voidonBlurFires when the textarea loses focus.
(event: React.FocusEvent<HTMLTextAreaElement>) => voiddataTestA selector hook into the React component for use in automated testing environments. It is
applied internally to the <textarea /> element.
string