forked from alan2207/bulletproof-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
InputField.tsx
26 lines (23 loc) · 860 Bytes
/
InputField.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import clsx from 'clsx';
import { UseFormRegisterReturn } from 'react-hook-form';
import { FieldWrapper, FieldWrapperPassThroughProps } from './FieldWrapper';
type InputFieldProps = FieldWrapperPassThroughProps & {
type?: 'text' | 'email' | 'password';
className?: string;
registration: Partial<UseFormRegisterReturn>;
};
export const InputField = (props: InputFieldProps) => {
const { type = 'text', label, className, registration, error } = props;
return (
<FieldWrapper label={label} error={error}>
<input
type={type}
className={clsx(
'appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm',
className
)}
{...registration}
/>
</FieldWrapper>
);
};