import type { InputHTMLAttributes, ReactNode } from "react"; interface InputProps extends InputHTMLAttributes { label?: string; error?: string; helperText?: string; icon?: ReactNode; } export function Input({ label, error, helperText, icon, id, className, ...rest }: InputProps) { const errorId = error && id ? `${id}-error` : undefined; const helperId = helperText && id ? `${id}-helper` : undefined; const describedBy = [errorId, helperId].filter(Boolean).join(" ") || undefined; return ( {label && ( {label} )} {icon && ( {icon} )} {error && ( {error} )} {helperText && !error && ( {helperText} )} ); }
{error}
{helperText}