content logo

React Forms:

Animation Login/Register Forms Relocation by React JS

To log in to your account on your website, you need the form that we have prepared for you in this post. If the user clicks on the login button in the register form, the form moves and the login form is displayed. Also, if the user clicks on the register button in the login form, the form moves to the right and a field is added to the form to enter the details. This form can be used for brightly themed websites.

#

Moving HTML Form Code

#

React Login Register Forms

#

HTML Animating Form

#

Animaing HTML Form Relocating

<!-- This script got from frontendfreecode.com -->
<div id="root"></div><a style="font-size: 8pt; text-decoration: none" target="_blank" href="http://frontendfreecode.com">Free Frontend</a>
                                                                            
.container {
	display: flex;
	justify-content: space-around;
	align-items: center;
	max-width: 500px;
	margin: 30vh auto;
}
.form-div {
	z-index: 1;
}
.form-div, .button-div {
	transition: .5s ease-out;
}
form {
	border: 1px solid lightgray;
	border-radius: 5px;
	display: flex;
	flex-direction: column;
	background-color: white;
}
input, button {
	margin: 5px;
}
input[type="text"], input[type="password"], textarea, select {
	height: 38px;
	padding: 6px 10px;
	background-color: #fff;
	border: 1px solid #D1D1D1;
	border-radius: 4px;
	box-shadow: none;
	box-sizing: border-box;
}
input[type="text"]:focus, input[type="password"]:focus, textarea:focus {
	border: 1px solid #2BCC9E;
	outline: 0;
}
.button, button, input[type="submit"], input[type="reset"], input[type="button"] {
	display: inline-block;
	height: 38px;
	padding: 0 30px;
	color: #555;
	text-align: center;
	font-size: 11px;
	font-weight: 600;
	line-height: 38px;
	letter-spacing: .1rem;
	text-transform: uppercase;
	text-decoration: none;
	white-space: nowrap;
	background-color: transparent;
	border-radius: 4px;
	border: 1px solid #bbb;
	cursor: pointer;
	box-sizing: border-box;
}
.button:hover, button:hover, input[type="submit"]:hover, input[type="reset"]:hover, input[type="button"]:hover, .button:focus, button:focus, input[type="submit"]:focus, input[type="reset"]:focus, input[type="button"]:focus {
	color: #333;
	border-color: #888;
	outline: 0;
}
.button.button-primary, button.button-primary, input[type="submit"].button-primary, input[type="reset"].button-primary, input[type="button"].button-primary {
	color: #FFF;
	background-color: #2BCC9E;
	border-color: #2BCC9E;
}
.button.button-primary:hover, button.button-primary:hover, input[type="submit"].button-primary:hover, input[type="reset"].button-primary:hover, input[type="button"].button-primary:hover, .button.button-primary:focus, button.button-primary:focus, input[type="submit"].button-primary:focus, input[type="reset"].button-primary:focus, input[type="button"].button-primary:focus {
	color: #FFF;
	background-color: #3FB594;
	border-color: #3FB594;
}
class App extends React.Component {
  constructor() {
    super();
    this.state = { form: 'login' };
 
    this.toggle = {
      login: 'register',
      register: 'login' };
  }
  onSubmit(e) {
    e.preventDefault();
  }
  render() {
    return /*#__PURE__*/(
      React.createElement("div", { className: "container" }, /*#__PURE__*/
      React.createElement("div", { style: { transform: `translate(${this.state.form === 'login' ? 0 : 250}px, 0px)` }, className: "form-div" }, /*#__PURE__*/
      React.createElement("form", { onSubmit: this.onSubmit.bind(this) }, /*#__PURE__*/
      React.createElement("input", { placeholder: "Email", type: "text" }), /*#__PURE__*/
      React.createElement("input", { placeholder: "Password", type: "password" }),
      this.state.form === 'login' ? '' : /*#__PURE__*/React.createElement("input", { placeholder: "Re-typed password", type: "password" }), /*#__PURE__*/
      React.createElement("button", { className: "button-primary" }, "Submit"))), /*#__PURE__*/
      React.createElement("div", { style: { transform: `translate(${this.state.form === 'login' ? 0 : -250}px, 0px)` }, className: "button-div" }, /*#__PURE__*/
      React.createElement("p", null, this.state.form === 'login' ? 'Do not have an account?' : 'Already a member?'), /*#__PURE__*/
      React.createElement("button", { onClick: () => {this.setState({ form: this.toggle[this.state.form] });} }, this.toggle[this.state.form]))));
  }}
ReactDOM.render( /*#__PURE__*/React.createElement(App, null), document.querySelector("#root"));
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react-dom.min.js'></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- This script got from frontendfreecode.com -->

<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react-dom.min.js'></script>
<style>
.container {
	display: flex;
	justify-content: space-around;
	align-items: center;
	max-width: 500px;
	margin: 30vh auto;
}
.form-div {
	z-index: 1;
}
.form-div, .button-div {
	transition: .5s ease-out;
}
form {
	border: 1px solid lightgray;
	border-radius: 5px;
	display: flex;
	flex-direction: column;
	background-color: white;
}
input, button {
	margin: 5px;
}
input[type="text"], input[type="password"], textarea, select {
	height: 38px;
	padding: 6px 10px;
	background-color: #fff;
	border: 1px solid #D1D1D1;
	border-radius: 4px;
	box-shadow: none;
	box-sizing: border-box;
}
input[type="text"]:focus, input[type="password"]:focus, textarea:focus {
	border: 1px solid #2BCC9E;
	outline: 0;
}
.button, button, input[type="submit"], input[type="reset"], input[type="button"] {
	display: inline-block;
	height: 38px;
	padding: 0 30px;
	color: #555;
	text-align: center;
	font-size: 11px;
	font-weight: 600;
	line-height: 38px;
	letter-spacing: .1rem;
	text-transform: uppercase;
	text-decoration: none;
	white-space: nowrap;
	background-color: transparent;
	border-radius: 4px;
	border: 1px solid #bbb;
	cursor: pointer;
	box-sizing: border-box;
}
.button:hover, button:hover, input[type="submit"]:hover, input[type="reset"]:hover, input[type="button"]:hover, .button:focus, button:focus, input[type="submit"]:focus, input[type="reset"]:focus, input[type="button"]:focus {
	color: #333;
	border-color: #888;
	outline: 0;
}
.button.button-primary, button.button-primary, input[type="submit"].button-primary, input[type="reset"].button-primary, input[type="button"].button-primary {
	color: #FFF;
	background-color: #2BCC9E;
	border-color: #2BCC9E;
}
.button.button-primary:hover, button.button-primary:hover, input[type="submit"].button-primary:hover, input[type="reset"].button-primary:hover, input[type="button"].button-primary:hover, .button.button-primary:focus, button.button-primary:focus, input[type="submit"].button-primary:focus, input[type="reset"].button-primary:focus, input[type="button"].button-primary:focus {
	color: #FFF;
	background-color: #3FB594;
	border-color: #3FB594;
}
</style>

</head>
<body>
<div id="root"></div><div id="bcl"><a style="font-size:8pt;text-decoration:none;" href="http://www.devanswer.com">Free Frontend</a></div>
<script>
class App extends React.Component {
  constructor() {
    super();
    this.state = { form: 'login' };
 
    this.toggle = {
      login: 'register',
      register: 'login' };
  }
  onSubmit(e) {
    e.preventDefault();
  }
  render() {
    return /*#__PURE__*/(
      React.createElement("div", { className: "container" }, /*#__PURE__*/
      React.createElement("div", { style: { transform: `translate(${this.state.form === 'login' ? 0 : 250}px, 0px)` }, className: "form-div" }, /*#__PURE__*/
      React.createElement("form", { onSubmit: this.onSubmit.bind(this) }, /*#__PURE__*/
      React.createElement("input", { placeholder: "Email", type: "text" }), /*#__PURE__*/
      React.createElement("input", { placeholder: "Password", type: "password" }),
      this.state.form === 'login' ? '' : /*#__PURE__*/React.createElement("input", { placeholder: "Re-typed password", type: "password" }), /*#__PURE__*/
      React.createElement("button", { className: "button-primary" }, "Submit"))), /*#__PURE__*/
      React.createElement("div", { style: { transform: `translate(${this.state.form === 'login' ? 0 : -250}px, 0px)` }, className: "button-div" }, /*#__PURE__*/
      React.createElement("p", null, this.state.form === 'login' ? 'Do not have an account?' : 'Already a member?'), /*#__PURE__*/
      React.createElement("button", { onClick: () => {this.setState({ form: this.toggle[this.state.form] });} }, this.toggle[this.state.form]))));
  }}
ReactDOM.render( /*#__PURE__*/React.createElement(App, null), document.querySelector("#root"));
</script>

</body>
</html>
Preview