import { InputHTMLAttributes } from "react";
interface InputProps extends InputHTMLAttributes {
label?: string;
error?: string;
/** Texto fijo grisado antes del campo (ej: el prefijo de país del teléfono). */
prefijo?: string;
ayuda?: string;
}
export default function Input({ label, error, prefijo, ayuda, className = "", id, ...props }: InputProps) {
const estiloInput = `border rounded-lg px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition bg-gray-100 text-gray-900 placeholder-gray-500 ${
error ? "border-red-400" : "border-gray-400"
} ${className}`;
return (
{label && (
)}
{prefijo ? (
{prefijo}
) : (
)}
{ayuda && !error &&
{ayuda}
}
{error &&
{error}
}
);
}