feat: add input with a leading icon
This commit is contained in:
parent
cba840a66f
commit
0317387105
22
app/components/ui/icon-input.tsx
Normal file
22
app/components/ui/icon-input.tsx
Normal file
@ -0,0 +1,22 @@
|
||||
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>
|
||||
);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user