A textarea is a multi-line text field for user input.

Example

⌘ Cmd + ⌥ Option + 1

Properties

propertypropTyperequireddefaultdescription
displayErrorbool-falseShows error styling if true
focusbool-falseAuto focus the Textaraea if true
labelstring-nullText that describes the textarea
notestring-nullForm note for the input
isOptionalcustom-false Adds an optional label if there is a label provided
@param {Object} props Object of props

@returns {Error} Error or null
defaultValuestring--The default value of the textarea used on initial render
isDisabledbool--Prevents textarea from being modified and appears disabled
isReadOnlybool--Prevents textarea from being modified but doesn't appear disabled
isRequiredbool--Prevents textarea from being submitted without value
maxLengthnumber--Max length of the input value
onBlurfunc-- Function that fires when the textarea loses focus. It fires regardless of
whether the value has changed.
onChangefunc-- Function that fires when the textarea loses focus after the value
changes
onFocusfunc--Function that fires when the textarea gains focus
onInputfunc--Function that fires the the textarea value changes
onKeyDownfunc--Function that fires when a key is pressed down
placeholderstring--Textarea placeholder text
testSectionstring--Hook for automated JavaScript tests
valuestring--Text within the textarea

Usage

When text input includes multiple lines, you must use a textarea. Note: consider the CodeMirror component in Optimziely.git for advanced code input and editing capabilities.

Best Practices

Do

Use textarea for generic multi-line input

Use textarea for simple code input like a CSS rule, or small snippet of HTML

Don't

Only use textarea for multi-line input, otherwise always use a standard <Input>