forked from rajun/ar-test
23 lines
858 B
TypeScript
23 lines
858 B
TypeScript
import type { ReactNode } from 'react';
|
|
import type { LucideIcon } from 'lucide-react';
|
|
import { Input, type InputProps } from '~/components/ui/input';
|
|
import { cn } from '~/lib/utils';
|
|
|
|
interface IconInputProps extends InputProps {
|
|
icon: LucideIcon;
|
|
trailing?: ReactNode;
|
|
}
|
|
|
|
export function IconInput({ icon: Icon, trailing, className, ...props }: IconInputProps) {
|
|
return (
|
|
<div className='group relative'>
|
|
<Icon
|
|
size={17}
|
|
className='pointer-events-none absolute left-4 top-1/2 -translate-y-1/2 text-text-muted transition-colors group-focus-within:text-primary'
|
|
/>
|
|
<Input className={cn('pl-11', trailing && 'pr-16', className)} {...props} />
|
|
{trailing && <div className='absolute right-2 top-1/2 -translate-y-1/2'>{trailing}</div>}
|
|
</div>
|
|
);
|
|
}
|