Textarea

A textarea allows the users enter a multi-line, free-form text.

Props

NameDefaultDescription
defaultValue: stringInitial value of the textarea, only when it is uncontrolled.
value: stringValue of the textarea. If undefined, the component will be uncontrolled and the value will be managed internally.
label: stringText to be placed above the textarea.
name: stringName attribute of the textarea element.
helperText: stringHelper text to be placed above the textarea.
placeholder: stringText to be put as placeholder of the textarea.
disabled: booleanfalseIf true, the component will be disabled.
optional: booleanfalseIf true, the textarea will be optional, showing (Optional) next to the label. Otherwise, the field will be considered required and an error will be passed as a parameter to the OnBlur and onChange functions when it has not been filled.
verticalGrow: 'auto' | 'manual' | 'none''auto'Defines the textarea's ability to resize vertically. It can be:
  • 'auto': The textarea grows or shrinks automatically in order to fit the content.
  • 'manual': The height of the textarea is enabled to be manually modified.
  • 'none': The textarea has a fixed height and can't be modified.
rows: number4Number of rows of the textarea.
onChange: functionThis function will be called when the user types within the textarea. An object including the current value and the error (if the value entered is not valid) will be passed to this function. An example of this object is: { value: value, error: error }. If there is no error, error will not be defined.
onBlur: functionThis function will be called when the textarea loses the focus. An object including the textarea value and the error (if the value entered is not valid) will be passed to this function. An example of this object is: { value: value, error: error }. If there is no error, error will not be defined.
error: stringIf it is a defined value and also a truthy string, the component will change its appearance, showing the error below the textarea. If the defined value is an empty string, it will reserve a space below the component for a future error, but it would not change its look. In case of being undefined or null, both the appearance and the space for the error message would not be modified.
pattern: stringRegular expression that defines the valid format allowed by the textarea. This will be checked both when the textarea loses the focus and while typing within it. If the string entered does not match the pattern, the onBlur and onChange functions will be called with the current value and an internal error informing that this value does not match the pattern. If the pattern is met, the error parameter of both events will not be defined.
minLength: numberSpecifies the minimun length allowed by the textarea. This will be checked both when the input element loses the focus and while typing within it. If the string entered does not comply the minimum length, the onBlur and onChange functions will be called with the current value and an internal error informing that the value length does not comply the specified range. If a valid length is reached, the error parameter of both events will not be defined.
maxLength: numberSpecifies the maximum length allowed by the textarea. This will be checked both when the input element loses the focus and while typing within it. If the string entered does not comply the maximum length, the onBlur and onChange functions will be called with the current value and an internal error informing that the value length does not comply the specified range. If a valid length is reached, the error parameter of both events will not be defined.
autocomplete: string'off'HTML autocomplete attribute. Lets the user specify if any permission the user agent has to provide automated assistance in filling out the textarea value. Its value must be one of all the possible values of the HTML autocomplete attribute: 'on', 'off', 'email', 'username', 'new-password', ...
margin: string | objectSize of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge'). You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
size: string'medium'Size of the component ('small' | 'medium' | 'large' | 'fillParent').
tabIndex: number0Value of the tabindex attribute.
ref: objectReference to the component.

Examples

Controlled

Uncontrolled

Error handling