first commit
This commit is contained in:
34
resources/js/components/Field.tsx
Normal file
34
resources/js/components/Field.tsx
Normal file
@@ -0,0 +1,34 @@
|
||||
import React, {
|
||||
FC, HTMLInputTypeAttribute,
|
||||
ReactElement
|
||||
} from "react"
|
||||
|
||||
const Field: FC<FieldProps> = ({children, type = 'text', className = '', classNameForm = '', ...props}) => {
|
||||
|
||||
return <div className={`form-control ${classNameForm}`}>
|
||||
{children && <label className="block text-gray-900 dark:text-gray-200"
|
||||
htmlFor={props.id ?? undefined}>
|
||||
{children}
|
||||
</label>}
|
||||
<input className={`${className} w-full mt-2 rounded dark:bg-gray-700`}
|
||||
type={type}
|
||||
{...props}/>
|
||||
<div className={`error-message`} />
|
||||
</div>
|
||||
}
|
||||
|
||||
export default Field
|
||||
|
||||
interface FieldProps {
|
||||
children?: ReactElement|string,
|
||||
type?: HTMLInputTypeAttribute,
|
||||
name: string,
|
||||
id?: string,
|
||||
value: any,
|
||||
placeholder?: string,
|
||||
autoFocus?: boolean,
|
||||
className?: string,
|
||||
classNameForm?: string,
|
||||
step?: string,
|
||||
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void,
|
||||
}
|
||||
Reference in New Issue
Block a user