Skip to main content

TextareaField

Description

A multi-line text input field component that integrates with React Hook Form. Supports validation, error display, required fields, and helper text tooltips.

Import

import { TextareaField } from '@components/common/form/TextareaField';

Usage

import { Form } from '@components/common/form/Form';
import { TextareaField } from '@components/common/form/TextareaField';

function MyForm() {
return (
<Form action="/api/save">
<TextareaField
name="description"
label="Description"
rows={6}
required
/>
</Form>
);
}

Props

NameTypeDefaultDescription
nameFieldPath<T>-Field name (required)
labelstring-Label text displayed above the textarea
rowsnumber4Number of visible text rows
errorstring-Custom error message
helperTextstring-Helper text shown in a tooltip
requiredbooleanfalseMakes the field required
validationRegisterOptions<T>-React Hook Form validation rules
wrapperClassNamestring-CSS class for the wrapper div
classNamestring-CSS class for the textarea element
...propsTextareaHTMLAttributes-All standard HTML textarea attributes

Example: With Validation

import { Form } from '@components/common/form/Form';
import { TextareaField } from '@components/common/form/TextareaField';

function CommentForm() {
return (
<Form action="/api/comments">
<TextareaField
name="comment"
label="Comment"
placeholder="Enter your comment..."
rows={5}
required
validation={{
minLength: {
value: 10,
message: 'Comment must be at least 10 characters'
},
maxLength: {
value: 500,
message: 'Comment must not exceed 500 characters'
}
}}
/>
</Form>
);
}