CxJS

TextArea

import { TextArea } from 'cx/widgets'; Copied

The TextArea widget is used for multi-line text inputs. It extends TextField and inherits most of its properties.

<LabelsTopLayout vertical>
  <TextArea
    label="Standard"
    value={bind(m.text, "Hello World\nThis is a multi-line text.")}
    rows={3}
  />
  <TextArea label="Disabled" value={m.text} rows={3} disabled />
  <TextArea
    label="Placeholder"
    value={m.placeholder}
    rows={3}
    placeholder="Enter your message..."
  />
  <TextArea label="Required" value={m.text} rows={3} required />
</LabelsTopLayout>

Configuration

Core Properties

PropertyTypeDefaultDescription
valuestringnullText value of the input
rowsnumberNumber of visible text rows
placeholderstringHint text displayed when the field is empty
disabledbooleanfalseDisables the input
enabledbooleanOpposite of disabled
readOnlybooleanfalseMakes the input read-only
requiredbooleanfalseMarks the field as required
labelstringField label text
viewModebooleanfalseDisplay as plain text instead of interactive input
emptyTextstringText shown in view mode when the field is empty
reactOnstring"blur"Events that trigger value updates. Options: "input", "blur". Use "input" for real-time updates

Validation

PropertyTypeDefaultDescription
minLengthnumberMinimum allowed text length
maxLengthnumberMaximum allowed text length
minLengthValidationErrorTextstring"Enter {[{0}-{1}]} more character(s)."Error message when text is too short
maxLengthValidationErrorTextstring"Use {0} characters or fewer."Error message when text is too long
validationRegExpRegExpRegular expression for validating the input
validationErrorTextstring"The entered value is not valid."Error message when regex validation fails
trimbooleanfalseTrims whitespace before storing and validating
errorstringCustom error message. Field is marked invalid if set
visitedbooleanIf true, shows validation errors immediately
validationModestring"tooltip"How to show errors: "tooltip", "help", "help-block"

Appearance

PropertyTypeDefaultDescription
tooltipstring/objectTooltip text or configuration
inputStylestring/objectCSS styles applied to the textarea element
inputClassstringCSS class applied to the textarea element

Behavior

PropertyTypeDefaultDescription
autoFocusbooleanfalseAutomatically focuses the field on mount
trackFocusbooleanfalseAdds cxs-focus CSS class when input is focused
focusedbooleanBound value updated when field gains/loses focus
tabIndexstringCustom tab index
idstringHTML id attribute for the textarea

Callbacks

PropertyTypeDescription
onValidatefunction`(value, instance, validationParams) => string