<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

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/react-is/17.0.2/umd/react-is.production.min.js
  2. https://cdnjs.cloudflare.com/ajax/libs/react/17.0.2/umd/react.production.min.js
  3. https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.2/umd/react-dom.production.min.js