38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { forwardRef, type InputHTMLAttributes } from 'react'
|
|
import { clsx } from 'clsx'
|
|
|
|
interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
label?: string
|
|
error?: string
|
|
}
|
|
|
|
export const Input = forwardRef<HTMLInputElement, InputProps>(
|
|
({ className, label, error, id, ...props }, ref) => {
|
|
return (
|
|
<div className="w-full">
|
|
{label && (
|
|
<label htmlFor={id} className="block text-sm font-medium text-gray-300 mb-1.5">
|
|
{label}
|
|
</label>
|
|
)}
|
|
<input
|
|
ref={ref}
|
|
id={id}
|
|
className={clsx(
|
|
'w-full px-4 py-3 bg-dark-800 border rounded-lg text-white placeholder-gray-500',
|
|
'focus:outline-none focus:border-neon-500',
|
|
'focus:shadow-[0_0_0_3px_rgba(34,211,238,0.1),0_0_8px_rgba(34,211,238,0.15)]',
|
|
'transition-all duration-200',
|
|
error ? 'border-red-500' : 'border-dark-600',
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
{error && <p className="mt-1.5 text-sm text-red-400">{error}</p>}
|
|
</div>
|
|
)
|
|
}
|
|
)
|
|
|
|
Input.displayName = 'Input'
|