Skip to main content

Textarea

Textarea Field

The textarea field type provides a multi-line text input control, ideal for longer text entries like descriptions, comments, or addresses.

Basic Usage

{
fieldId: "basic_textarea",
type: "textarea",
label: "Comments",
placeholder: "Enter your comments here"
}

Props

PropTypeDescriptionDefault
type"textarea"Must be "textarea" to identify field typerequired
fieldIdstringUnique identifier for the fieldrequired
labelstringLabel text for the textareaoptional
placeholderstringPlaceholder textoptional
rowsnumberVisible number of text linesbrowser default
colsnumberVisible width in character columnsbrowser default
requiredbooleanWhether field is requiredfalse
classNamestringCSS classes for the textarea elementoptional
labelClassNamestringCSS classes for the label elementoptional
autoCorrectstringSpecifies autocorrect behavioroptional
autoCapitalizestringSpecifies autocapitalization behavioroptional
spellCheckbooleanSpecifies spellcheck behavioroptional
autoFocusbooleanWhether field should autofocusfalse
valuestringControlled field valueoptional
defaultValuestringUncontrolled default valueoptional

Features

Basic Configuration

{
fieldId: "address",
type: "textarea",
label: "Street Address",
placeholder: "123 Main St",
rows: 3,
required: true
}

Styling

Apply custom styles using classes:

{
fieldId: "styled_textarea",
type: "textarea",
label: "Feedback",
className: "border-2 border-blue-300 rounded-lg p-4 focus:ring-2 focus:ring-blue-500",
labelClassName: "text-lg font-medium text-gray-700 mb-2"
}

Textarea Dimensions

Control visible size with rows and cols:

{
fieldId: "large_textarea",
type: "textarea",
label: "Detailed Description",
rows: 8,
cols: 60
}

Text Input Features

Configure text input behavior:

{
fieldId: "optimized_textarea",
type: "textarea",
label: "Notes",
autoCorrect: "on",
autoCapitalize: "sentences",
spellCheck: true
}

Accessibility

Make your textarea accessible:

{
fieldId: "accessible_textarea",
type: "textarea",
label: "Special Instructions",
"aria-label": "Enter special instructions here",
"aria-describedby": "instructions-help"
}

Complete Examples

Standard Textarea with Validation

{
fieldId: "user_bio",
type: "textarea",
label: "Biography",
placeholder: "Tell us about yourself",
rows: 5,
required: true,
className: "border border-gray-300 rounded p-3 w-full",
labelClassName: "block mb-2 font-medium",
validation: [
{
minLength: 20,
message: "Biography should be at least 20 characters"
},
{
maxLength: 500,
message: "Biography cannot exceed 500 characters"
}
]
}
Clicky