"use client"; import { TextareaHTMLAttributes, forwardRef } from "react"; interface TextareaProps extends TextareaHTMLAttributes { label?: string; error?: string; showCharCount?: boolean; maxLength?: number; } const Textarea = forwardRef( ({ label, error, showCharCount, maxLength, className = "", value, ...props }, ref) => { const charCount = typeof value === "string" ? value.length : 0; return ( {label && ( {label} )} { e.target.style.borderColor = "var(--accent-color)"; }} onBlur={(e) => { e.target.style.borderColor = "var(--border)"; }} {...props} /> {showCharCount && maxLength && ( {charCount}/{maxLength} caractères )} {error && ( {error} )} ); } ); Textarea.displayName = "Textarea"; export default Textarea;
{charCount}/{maxLength} caractères
{error}