ishaq101's picture
[KM-422] [EMA][FE] Interface prototype for External Demo
1ed65e9
"use client";
import { forwardRef } from "react";
import { cn } from "@/lib/utils";
interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
label?: string;
error?: string;
icon?: React.ReactNode;
}
export const Input = forwardRef<HTMLInputElement, InputProps>(
({ className, label, error, icon, id, ...props }, ref) => {
return (
<div className="flex flex-col gap-1.5">
{label && (
<label htmlFor={id} className="text-sm font-medium text-neutral-700">
{label}
</label>
)}
<div className="relative">
{icon && (
<div className="absolute inset-y-0 left-0 pl-3.5 flex items-center pointer-events-none text-neutral-400">
{icon}
</div>
)}
<input
ref={ref}
id={id}
className={cn(
"w-full rounded-xl border border-neutral-200 bg-white px-4 py-3 text-sm text-neutral-900 placeholder:text-neutral-400",
"transition-all duration-200 outline-none",
"focus:border-brand-green focus:ring-3 focus:ring-brand-green/10",
"disabled:opacity-50 disabled:cursor-not-allowed",
error && "border-red-400 focus:border-red-400 focus:ring-red-400/10",
icon && "pl-10",
className
)}
{...props}
/>
</div>
{error && <p className="text-xs text-red-500">{error}</p>}
</div>
);
}
);
Input.displayName = "Input";