reusable input component

This commit is contained in:
BFlat committed 2023-08-11 12:34:54 +07:00
1 parent 66cd29ffe0
commit e2f3a308fb
1 file changed
+36
@@ -0,0 +1,36 @@
import React from "react";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { IconDefinition } from "@fortawesome/fontawesome-svg-core";
interface InputProps {
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
value?: string;
icon?: IconDefinition;
label?: string;
placeholder?: string;
type?: string;
}
export default function Input(props: InputProps) {
return (
<div>
{props.label && <label className="sub-title">{props.label}</label>}
<div className={`form-group ${props.icon ? "input-icon" : ""}`}>
{props.icon && (
<FontAwesomeIcon
icon={props.icon}
className="form-control-feedback"
/>
)}
<input
onChange={props.onChange}
className="form-control"
type={props.type && "text"}
placeholder={props.placeholder}
value={props.value}
/>
</div>
</div>
);
}