<div id='app'></div>
const App = ({}) => {
const inputRef = React.useRef(null);
const showPassword = () => {
inputRef.current.classList.add("green");
const currentType = inputRef.current.type;
inputRef.current.type = currentType === "text" ? "password" : "text";
};
return (
<>
<input ref={inputRef} type={"password"} />
<button onClick={showPassword}>show password</button>
</>
);
};
ReactDOM.render(<App />, document.getElementById("app"));
View Compiled
This Pen doesn't use any external CSS resources.