38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import { Search, X } from "lucide-react";
|
|
|
|
interface SearchInputProps {
|
|
value: string;
|
|
onChange: (value: string) => void;
|
|
placeholder?: string;
|
|
}
|
|
|
|
export const SearchInput = ({
|
|
value,
|
|
onChange,
|
|
placeholder = "Поиск...",
|
|
}: SearchInputProps) => {
|
|
return (
|
|
<div className="relative mb-4 w-full max-w-sm">
|
|
<Search
|
|
size={16}
|
|
className="absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"
|
|
/>
|
|
<input
|
|
type="text"
|
|
value={value}
|
|
onChange={(e) => onChange(e.target.value)}
|
|
placeholder={placeholder}
|
|
className="w-full pl-9 pr-8 py-2 border border-gray-300 rounded-md text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 bg-white"
|
|
/>
|
|
{value && (
|
|
<button
|
|
onClick={() => onChange("")}
|
|
className="absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600"
|
|
>
|
|
<X size={14} />
|
|
</button>
|
|
)}
|
|
</div>
|
|
);
|
|
};
|