Skip to main content

TextAreaField

A styled textarea input for forms, designed to integrate seamlessly with react-hook-form. It provides built-in support for validation errors and customizable styling.

๐Ÿ“ฆ Importโ€‹

import { TextareaField } from "@sahilphondekar/react-component-library";

๐Ÿงฑ Propsโ€‹

NameTypeDefaultDescription
labelstringโ€”Optional label displayed above the textarea
idstringโ€” (required)Unique identifier for the textarea
registerfunctionโ€” (required)react-hook-form's register method
errorMessagestringundefinedValidation error message displayed below the textarea
rowsnumber4Number of rows for the textarea (default is 4)
outerContainerClassNamestring""Class name for the outer wrapper
inputClassNamestring""Class name for the textarea element
labelClassNamestring""Class name for the label element
errorClassNamestring""Class name for the error message element

๐Ÿ’… Styling Notesโ€‹

  • Default styling:
    • w-full px-3 py-2 border rounded-lg resize-none focus:outline-none
  • Error message:
    • text-red-500 text-sm mt-1

๐Ÿงช Exampleโ€‹

<TextareaField
id="description"
label="Description"
rows={6}
register={register("description", { required: "Description is required" })}
errorMessage={errors.description?.message}
/>

๐Ÿง  Tipsโ€‹

  • The rows prop allows you to control the height of the textarea. The default value is 4.
  • You can customize the textarea's appearance using inputClassName and other props.