content logo

React Forms:

Responsive Login Form with React JS

Using simple forms can increase the loading speed of your site in addition to the full efficiency due to the lower volume of code. In this form, we have a form to log in to the account using React. This form is located in the middle of the page. Each field in this form has a purple icon. The icon is located at the top of both fields and is larger in size. It can also be replaced with the logo of your website or company.

#

Responsive React Form

#

React Sign in Form

#

Login Form Validator

#

HTML Responsive Sign in Form

<!-- This script got from frontendfreecode.com -->
<div id="app"></div><a style="font-size: 8pt; text-decoration: none" target="_blank" href="http://frontendfreecode.com">Free Frontend</a>
                                                                            
@charset "UTF-8";
@import 'https://fonts.googleapis.com/css?family=Lato';
body {
  font-family: "Lato", sans-serif;
}
.Modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #6ed3cf;
  background-size: cover;
  border-radius: 15px;
}
.Modal a {
  display: block;
  color: #9068be;
  font-size: 14px;
  text-align: center;
  text-decoration: none;
  margin: 4px 0 10px 0;
  margin: 10px;
}
.Modal a:hover {
  text-decoration: underline;
}
.Input {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  border-bottom: 1px solid #9068be;
  margin: 0 50px;
}
.Input input {
  border: 0;
  background: transparent;
  padding: 5px 15px;
  margin: 18px 4px 0 4px;
  color: white;
  font-family: "Lato", sans-serif;
  font-size: 15px;
}
.Input input[type=text] ~ label::before {
  content: "";
}
.Input input[type=password] ~ label::before {
  content: "";
}
label {
  font-family: FontAwesome;
  color: #9068be;
  font-size: 16px;
  margin-top: 17px;
}
label::before {
  opacity: 0.7;
}
form button {
  position: relative;
  margin: 15px 0 5px 0;
  left: 50%;
  transform: translateX(-50%);
  background: #e62739;
  border: none;
  border-radius: 15px;
  padding: 15px;
  color: white;
  width: 60%;
  font-family: "Lato", sans-serif;
  font-size: 20px;
  cursor: pointer;
}
.logo {
  text-align: center;
  color: #9068be;
}
.logo i {
  display: block;
  padding: 20px 0 0 0;
  font-size: 70px;
  transform: translateX(-5px);
  margin: 20px 0;
}
.logo span {
  color: white;
  text-transform: uppercase;
}
const ReactCSSTG = React.addons.CSSTransitionGroup;
class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      isVisible: true };
    this.handleSubmit = this.handleSubmit.bind(this);
    this.handleRemount = this.handleRemount.bind(this);
  }
  handleSubmit(e) {
    e.preventDefault();
    this.setState({
      isVisible: false },
    function () {
      console.log(this.state.isVisible);
    });
    return false;
  }
  handleRemount(e) {
    this.setState({
      isVisible: true },
    function () {
      console.log(this.state.isVisible);
    });
    e.preventDefault();
  }
  render() {
    let component = this.state.isVisible ? /*#__PURE__*/React.createElement(Modal, { onSubmit: this.handleSubmit, key: "modal" }) : /*#__PURE__*/React.createElement(ModalBack, { onClick: this.handleRemount, key: "bringitback" });
    return /*#__PURE__*/React.createElement(ReactCSSTG, { transitionName: "animation", transitionAppear: true, transitionAppearTimeout: 500, transitionEnterTimeout: 500, transitionLeaveTimeout: 300 },
    component);
  }}
class Modal extends React.Component {
  render() {
    return /*#__PURE__*/React.createElement("div", { className: "Modal" }, /*#__PURE__*/
    React.createElement(Logo, null), /*#__PURE__*/
    React.createElement("form", { onSubmit: this.props.onSubmit }, /*#__PURE__*/
    React.createElement(Input, { type: "text", name: "username", placeholder: "username" }), /*#__PURE__*/
    React.createElement(Input, { type: "password", name: "password", placeholder: "password" }), /*#__PURE__*/
    React.createElement("button", null, " Sign In")), /*#__PURE__*/
    React.createElement("a", { href: "#" }, "Lost your password ?"));
  }}
class Input extends React.Component {
  render() {
    return /*#__PURE__*/React.createElement("div", { className: "Input" }, /*#__PURE__*/
    React.createElement("input", { type: this.props.type, name: this.props.name, placeholder: this.props.placeholder, required: true, autocomplete: "false" }), /*#__PURE__*/
    React.createElement("label", { for: this.props.name }));
  }}
class Logo extends React.Component {
  render() {
    return /*#__PURE__*/React.createElement("div", { className: "logo" }, /*#__PURE__*/
    React.createElement("i", { className: "fa fa-rocket", "aria-hidden": "true" }), /*#__PURE__*/
    React.createElement("span", null, " Welcome "));
  }}
class ModalBack extends React.Component {
  render() {
    return /*#__PURE__*/React.createElement("button", { className: "bringitback", onClick: this.props.onClick, key: this.props.className }, "Bring the form back!");
  }}
ReactDOM.render( /*#__PURE__*/React.createElement(App, null), document.getElementById('app'));
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css'>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react-with-addons.min.js'></script>
<script src='https://npmcdn.com/react-dom@15.3.0/dist/react-dom.min.js'></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- This script got from frontendfreecode.com -->

<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css'>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react-with-addons.min.js'></script>
<script src='https://npmcdn.com/react-dom@15.3.0/dist/react-dom.min.js'></script>
<style>
@charset "UTF-8";
@import 'https://fonts.googleapis.com/css?family=Lato';
body {
  font-family: "Lato", sans-serif;
}
.Modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #6ed3cf;
  background-size: cover;
  border-radius: 15px;
}
.Modal a {
  display: block;
  color: #9068be;
  font-size: 14px;
  text-align: center;
  text-decoration: none;
  margin: 4px 0 10px 0;
  margin: 10px;
}
.Modal a:hover {
  text-decoration: underline;
}
.Input {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  border-bottom: 1px solid #9068be;
  margin: 0 50px;
}
.Input input {
  border: 0;
  background: transparent;
  padding: 5px 15px;
  margin: 18px 4px 0 4px;
  color: white;
  font-family: "Lato", sans-serif;
  font-size: 15px;
}
.Input input[type=text] ~ label::before {
  content: "";
}
.Input input[type=password] ~ label::before {
  content: "";
}
label {
  font-family: FontAwesome;
  color: #9068be;
  font-size: 16px;
  margin-top: 17px;
}
label::before {
  opacity: 0.7;
}
form button {
  position: relative;
  margin: 15px 0 5px 0;
  left: 50%;
  transform: translateX(-50%);
  background: #e62739;
  border: none;
  border-radius: 15px;
  padding: 15px;
  color: white;
  width: 60%;
  font-family: "Lato", sans-serif;
  font-size: 20px;
  cursor: pointer;
}
.logo {
  text-align: center;
  color: #9068be;
}
.logo i {
  display: block;
  padding: 20px 0 0 0;
  font-size: 70px;
  transform: translateX(-5px);
  margin: 20px 0;
}
.logo span {
  color: white;
  text-transform: uppercase;
}
</style>

</head>
<body>
<div id="app"></div><div id="bcl"><a style="font-size:8pt;text-decoration:none;" href="http://www.devanswer.com">Free Frontend</a></div>
<script>
const ReactCSSTG = React.addons.CSSTransitionGroup;
class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      isVisible: true };
    this.handleSubmit = this.handleSubmit.bind(this);
    this.handleRemount = this.handleRemount.bind(this);
  }
  handleSubmit(e) {
    e.preventDefault();
    this.setState({
      isVisible: false },
    function () {
      console.log(this.state.isVisible);
    });
    return false;
  }
  handleRemount(e) {
    this.setState({
      isVisible: true },
    function () {
      console.log(this.state.isVisible);
    });
    e.preventDefault();
  }
  render() {
    let component = this.state.isVisible ? /*#__PURE__*/React.createElement(Modal, { onSubmit: this.handleSubmit, key: "modal" }) : /*#__PURE__*/React.createElement(ModalBack, { onClick: this.handleRemount, key: "bringitback" });
    return /*#__PURE__*/React.createElement(ReactCSSTG, { transitionName: "animation", transitionAppear: true, transitionAppearTimeout: 500, transitionEnterTimeout: 500, transitionLeaveTimeout: 300 },
    component);
  }}
class Modal extends React.Component {
  render() {
    return /*#__PURE__*/React.createElement("div", { className: "Modal" }, /*#__PURE__*/
    React.createElement(Logo, null), /*#__PURE__*/
    React.createElement("form", { onSubmit: this.props.onSubmit }, /*#__PURE__*/
    React.createElement(Input, { type: "text", name: "username", placeholder: "username" }), /*#__PURE__*/
    React.createElement(Input, { type: "password", name: "password", placeholder: "password" }), /*#__PURE__*/
    React.createElement("button", null, " Sign In")), /*#__PURE__*/
    React.createElement("a", { href: "#" }, "Lost your password ?"));
  }}
class Input extends React.Component {
  render() {
    return /*#__PURE__*/React.createElement("div", { className: "Input" }, /*#__PURE__*/
    React.createElement("input", { type: this.props.type, name: this.props.name, placeholder: this.props.placeholder, required: true, autocomplete: "false" }), /*#__PURE__*/
    React.createElement("label", { for: this.props.name }));
  }}
class Logo extends React.Component {
  render() {
    return /*#__PURE__*/React.createElement("div", { className: "logo" }, /*#__PURE__*/
    React.createElement("i", { className: "fa fa-rocket", "aria-hidden": "true" }), /*#__PURE__*/
    React.createElement("span", null, " Welcome "));
  }}
class ModalBack extends React.Component {
  render() {
    return /*#__PURE__*/React.createElement("button", { className: "bringitback", onClick: this.props.onClick, key: this.props.className }, "Bring the form back!");
  }}
ReactDOM.render( /*#__PURE__*/React.createElement(App, null), document.getElementById('app'));
</script>

</body>
</html>
Preview