2023-11-08 12:02:00 +03:00

30 lines
1006 B
TypeScript

import { cn } from './utils';
import type { VariantProps } from 'class-variance-authority';
import { cva } from 'class-variance-authority';
import { forwardRef } from 'react';
const variants = cva(
'block w-full rounded-sm border border-gray-300 p-2 text-sm text-gray-900 outline-none transition-all ease-linear hover:border-primary-500 hover:transition-all focus:border-primary-500 focus:transition-all'
);
export type InputProps = React.InputHTMLAttributes<HTMLInputElement> &
VariantProps<typeof variants>;
export const Input = forwardRef<HTMLInputElement, InputProps>(({ className, ...props }, ref) => (
<div className="flex flex-col">
<label
htmlFor={props.id}
className="mb-1 block overflow-hidden overflow-ellipsis whitespace-nowrap text-sm font-medium text-black text-opacity-90"
>
{props.title}
</label>
<input
ref={ref}
type={props.type}
id={props.id}
className={cn(variants({ className }))}
{...props}
/>
</div>
));