You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

25 lines
585 B

import "./input.css";
import { useState, useRef } from "react";
const TextInput = ({ name, label, required, inner_type }) => {
const [lc, setLc] = useState("");
const inputRef = useRef();
const a = () => {
setLc("label-with-focus");
};
const b = () => {
if (inputRef.current.value.length === 0) {
setLc("");
}
};
return (
<>
<div className="text-input">
<label className={lc}>{"نام کاربری"}</label>
<input ref={inputRef} type={"text"} onFocus={a} onBlur={b} />
</div>
</>
);
};
export default TextInput;