input with icon

This commit is contained in:
Yash 2024-04-02 11:36:40 +00:00
parent 531c054163
commit 90eb9429fd

View file

@ -20,6 +20,30 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
);
},
);
Input.displayName = "Input";
export { Input };
export interface InputWithIconProps
extends React.InputHTMLAttributes<HTMLInputElement> {
icon: React.ReactNode;
}
const InputWithIcon = React.forwardRef<HTMLInputElement, InputWithIconProps>(
({ className, type, icon, ...props }, ref) => {
return (
<div className="border-rgray-6 text-rgray-12 ring-offset-rgray-2 focus-within:ring-rgray-7 flex h-10 w-full items-center justify-center gap-2 rounded-md border bg-transparent px-3 py-2 text-sm transition focus-within:outline-none focus-within:ring-2 focus-within:ring-offset-2 ">
{icon}
<input
type={type}
className={cn(
"placeholder:text-rgray-11 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:cursor-not-allowed disabled:opacity-50 ",
className,
)}
ref={ref}
{...props}
/>
</div>
);
},
);
InputWithIcon.displayName = "Input";
export { Input, InputWithIcon };