screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <script src="https://unpkg.com/react@17.0.2/umd/react.development.js"></script> <script src="https://unpkg.com/react-dom@17.0.2/umd/react-dom.development.js"></script> <script src="https://cdn.jsdelivr.net/npm/@babel/standalone@7.14.6/babel.min.js"></script> </head> <body> <div id="app"></div> <script type="text/babel" data-presets="env,react"> const { useState } = React; function App() { const [inputType, setInputType] = useState("password"); const [showHidebtnText, setShowHideBtnText] = useState("Show"); const toggleInput = () => { setInputType(inputType === "password" ? "text" : "password"); setShowHideBtnText(showHidebtnText === "Show" ? "Hide" : "Show"); }; return ( <div class='container'> <h3>React Js Show Hide Passowrd in Login Form</h3> <form className="form"> <div className="fieldset"> <label className="email" htmlFor="signin-email"> E-mail </label> <input className="signin-email" type="email" placeholder="E-mail" /> </div> <div className="fieldset"> <label className="password" htmlFor="signin-password"> Password </label> <span style={{ display: "flex" }}> <input className="signin-password" type={inputType} placeholder="Password" /> <button className="hide-password" type="button" onClick={toggleInput} > <span>{showHidebtnText}</span> </button> </span> </div> <div className="fieldset"> <input type="checkbox" id="remember-me" checked /> <label htmlFor="remember-me">Remember me</label> </div> <button className="login-btn" type="submit"> Login </button> </form> </div> ); } ReactDOM.render(<App />, document.getElementById("app")); </script> <style> .container { width: 100%; max-width: 400px; margin: 0 auto; padding: 20px; background-color: #f5f5f5; } .form { display: flex; flex-direction: column; } .fieldset { margin-bottom: 20px; } .label { font-weight: bold; } .email, .password { display: block; margin-bottom: 5px; } .signin-email, .signin-password { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; } .hide-password { background-color: transparent; border: none; cursor: pointer; outline: none; } #remember-me { margin-right: 10px; } .login-btn { padding: 10px; background-color: #4caf50; color: #fff; border: none; border-radius: 4px; cursor: pointer; } .login-btn:hover { background-color: #45a049; } .login-btn:active { background-color: #3c903c; } </style> </body> </html>