TextareaField
A multi-line text input with validation.
The TextareaField is ideal for longer text input like bios or descriptions.
Preview
"use client";
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm, FormProvider } from "react-hook-form";
import { z } from "zod";
import TextareaField from "@/components/ui/TextareaField";
import { schema } from "./textarea-field-schema";
export function TextareaFieldBasicExample() {
const methods = useForm<z.infer<typeof schema>>({
resolver: zodResolver(schema),
defaultValues: {
bio: "",
},
});
const onSubmit = (data: z.infer<typeof schema>) => {
console.log("Form data:", data);
alert("Check the console for the form data!");
};
return (
<FormProvider {...methods}>
<form
onSubmit={methods.handleSubmit(onSubmit)}
className="space-y-4 w-80"
>
<TextareaField
name="bio"
label="Bio"
placeholder="Tell us about yourself..."
/>
<button
type="submit"
className="form-button form-button-primary w-full"
>
Submit
</button>
</form>
</FormProvider>
);
}
Props
| Name | Type | Default | Description |
|---|---|---|---|
| name* | string | - | The name attribute used for form registration. |
| label | string | - | Label displayed above the textarea. |
| placeholder | string | - | Placeholder text for the textarea. |