-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathInput.jsx
More file actions
34 lines (26 loc) · 1020 Bytes
/
Input.jsx
File metadata and controls
34 lines (26 loc) · 1020 Bytes
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
27
28
29
30
31
32
33
34
import { useState } from "react";
const InputBox = ({ name, type, id, value, placeholder, icon, disable = false }) => {
const [ passwordVisible, setPasswordVisible ] = useState(false);
return (
<div className="relative w-[100%] mb-4">
<input
name={name}
type={ type == "password" ? passwordVisible ? "text" : "password" : type }
placeholder={placeholder}
defaultValue={value}
id={id}
disabled={disable}
className="input-box"
/>
<i className={"fi " + icon + " input-icon"}></i>
{
type == "password" ?
<i className={"fi fi-rr-eye" + (!passwordVisible ? "-crossed" : "") + " input-icon left-[auto] right-4 cursor-pointer"}
onClick={() => setPasswordVisible(currentVal => !currentVal)}
></i>
: ""
}
</div>
)
}
export default InputBox;