import { forwardRef, useId, type TextareaHTMLAttributes } from 'react';
import { cn } from '../utils/cn';
interface Props extends TextareaHTMLAttributes {
label?: string;
hint?: string;
error?: string;
containerClassName?: string;
}
export const TextArea = forwardRef(function TextArea(
{ label, hint, error, className, containerClassName, id, required, rows = 4, ...rest },
ref,
) {
const generatedId = useId();
const taId = id || generatedId;
const describedBy = error
? `${taId}-error`
: hint
? `${taId}-hint`
: undefined;
return (
{label && (
)}
{hint && !error && (
{hint}
)}
{error && (
{error}
)}
);
});