Files
game-marathon/frontend/src/components/ui/Input.tsx

38 lines
1.1 KiB
TypeScript
Raw Normal View History

2025-12-14 02:38:35 +07:00
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 && (
2025-12-17 02:03:33 +07:00
<label htmlFor={id} className="block text-sm font-medium text-gray-300 mb-1.5">
2025-12-14 02:38:35 +07:00
{label}
</label>
)}
<input
ref={ref}
id={id}
className={clsx(
2025-12-17 02:03:33 +07:00
'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(0,240,255,0.1),0_0_10px_rgba(0,240,255,0.2)]',
'transition-all duration-200',
error ? 'border-red-500' : 'border-dark-600',
2025-12-14 02:38:35 +07:00
className
)}
{...props}
/>
2025-12-17 02:03:33 +07:00
{error && <p className="mt-1.5 text-sm text-red-400">{error}</p>}
2025-12-14 02:38:35 +07:00
</div>
)
}
)
Input.displayName = 'Input'