Skip to content
Snippets Groups Projects
Commit 1cfa1e12 authored by Matt Kirby's avatar Matt Kirby
Browse files

Added basic field form component

parent 0e111d29
No related branches found
No related tags found
No related merge requests found
import { FC } from "react"
type BasicFieldProps = {
name: string,
placeholder: string,
error?: string | null
onChange: (value: string) => void;
}
const BasicField:FC<BasicFieldProps> = ({
name,
placeholder,
error,
onChange
}) => {
const handleChange = (value: string) => {
onChange(value)
}
return (
<div className="mb-3">
<label htmlFor={name} className="sr-only">
{placeholder}
</label>
<input
id={name}
name={name}
type={name}
autoComplete={name}
required
className={`p-3 relative block w-full rounded-md border-0 py-1.5 text-gray-900 ring-1 ring-inset placeholder:text-gray-400 focus:z-10 sm:text-sm sm:leading-6 ${error ? "ring-c-pink" : "ring-gray-300"}`}
placeholder={placeholder}
onChange={e => handleChange(e.target.value)}
/>
<p className="text-xs text-c-pink m-1">
{error}
</p>
</div>
)
}
export default BasicField
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment