content logo

React Forms:

Simple React Login Form with Image Background

As you can see in this post we have a form that can be used to login to the account. This form is located in the middle of the page and is the button for registering information and entering the user area in blue. The background of this image form is a bridge. This form is responsive and is made using React and can be used for structural design websites.

#

Free React Form

#

React Form with Image

#

React Signin Form

#

CSS Form Background Image

#

Responsive React Form

<!-- 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>
                                                                            
html {
  box-sizing: border-box;
}
*,
*:after,
*:before {
  box-sizing: border-box;
}
body {
  font-family: "Roboto", sans-serif;
}
#root {
  background: url("http://frontendfreecode.com/img/photo-red-bridge.jpg") no-repeat center/cover;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  height: 100%;
  width: 100%;
}
.react-form {
  width: 300px;
  border-radius: 5px;
  background: white;
  box-shadow: 0 15px 35px rgba(50, 50, 93, 0.1), 0 5px 15px rgba(0, 0, 0, 0.07);
  padding: 20px;
  text-align: center;
}
h1 {
  color: #333;
  font-size: 24px;
  margin-top: 0;
}
input {
  border: none;
  border-bottom: 1px solid #333;
  background: none;
  width: 100%;
  font-size: 18px;
  font-weight: bold;
  line-height: 1.2;
  outline: none;
}
.btn:hover {
  background: #0278dd;
  border-color: #0278dd;
}
const {
  HashRouter,
  Switch,
  Route } =
ReactRouterDOM;
const App = () => /*#__PURE__*/
React.createElement(Switch, null, /*#__PURE__*/
React.createElement(Route, { exact: true, path: "/", component: ReactForm }), /*#__PURE__*/
React.createElement(Route, { path: "/success", component: Success }));
class ReactLabel extends React.Component {
  constructor() {
    super();
  }
  render() {
    return /*#__PURE__*/React.createElement("label", { htmlFor: this.props.htmlFor }, this.props.title);
  }}
class ReactForm extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      username: "",
      password: "",
      valid: true };
    this.handleSubmit = this.handleSubmit.bind(this);
  }
  handleSubmit(e) {
    var input = this.refs.myInput;
    var inputValue = input.value;
    if (inputValue !== "test") {
      this.setState({
        valid: false });
    } else {
      this.state.valid && this.props.history.push('/success');
    }
  }
  render() {
    let formClass = "react-form";
    !this.state.valid && (formClass += " error");
    return /*#__PURE__*/(
      React.createElement("form", { className: formClass, onSubmit: this.handleSubmit }, /*#__PURE__*/
      React.createElement("fieldset", { className: "form-group" }, /*#__PURE__*/
      React.createElement(ReactLabel, { htmlFor: "formName", title: "Username:" }), /*#__PURE__*/
      React.createElement("input", {
        id: "formName",
        className: "form-input",
        name: "username",
        type: "text" })), /*#__PURE__*/
      React.createElement("fieldset", { className: "form-group" }, /*#__PURE__*/
      React.createElement(ReactLabel, { htmlFor: "formPassword", title: "Password:" }), /*#__PURE__*/
      React.createElement("input", {
        id: "formPassword",
        ref: "myInput",
        className: "form-input",
        name: "password",
        type: "text" })),
      !this.state.valid && /*#__PURE__*/React.createElement("p", { className: "alert-danger" }, "Please try again"), /*#__PURE__*/
      React.createElement("input", {
        id: "formButton",
        className: "btn btn-primary",
        type: "submit",
        placeholder: "Send message" })));
  }}
const Success = () => /*#__PURE__*/
React.createElement("h2", null, "Thank you!");
ReactDOM.render( /*#__PURE__*/
React.createElement(HashRouter, null, /*#__PURE__*/
React.createElement(App, null)),
document.getElementById('root'));
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
    <link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Roboto'>
    <link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css'>
        <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>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react-router-dom/4.4.0/react-router-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/normalize/5.0.0/normalize.min.css">
    <link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Roboto'>
    <link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css'>
        <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>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react-router-dom/4.4.0/react-router-dom.min.js" ></script>  
<style>
html {
  box-sizing: border-box;
}
*,
*:after,
*:before {
  box-sizing: border-box;
}
body {
  font-family: "Roboto", sans-serif;
}
#root {
  background: url("http://frontendfreecode.com/img/photo-red-bridge.jpg") no-repeat center/cover;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  height: 100%;
  width: 100%;
}
.react-form {
  width: 300px;
  border-radius: 5px;
  background: white;
  box-shadow: 0 15px 35px rgba(50, 50, 93, 0.1), 0 5px 15px rgba(0, 0, 0, 0.07);
  padding: 20px;
  text-align: center;
}
h1 {
  color: #333;
  font-size: 24px;
  margin-top: 0;
}
input {
  border: none;
  border-bottom: 1px solid #333;
  background: none;
  width: 100%;
  font-size: 18px;
  font-weight: bold;
  line-height: 1.2;
  outline: none;
}
.btn:hover {
  background: #0278dd;
  border-color: #0278dd;
}
</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>
const {
  HashRouter,
  Switch,
  Route } =
ReactRouterDOM;
const App = () => /*#__PURE__*/
React.createElement(Switch, null, /*#__PURE__*/
React.createElement(Route, { exact: true, path: "/", component: ReactForm }), /*#__PURE__*/
React.createElement(Route, { path: "/success", component: Success }));
class ReactLabel extends React.Component {
  constructor() {
    super();
  }
  render() {
    return /*#__PURE__*/React.createElement("label", { htmlFor: this.props.htmlFor }, this.props.title);
  }}
class ReactForm extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      username: "",
      password: "",
      valid: true };
    this.handleSubmit = this.handleSubmit.bind(this);
  }
  handleSubmit(e) {
    var input = this.refs.myInput;
    var inputValue = input.value;
    if (inputValue !== "test") {
      this.setState({
        valid: false });
    } else {
      this.state.valid && this.props.history.push('/success');
    }
  }
  render() {
    let formClass = "react-form";
    !this.state.valid && (formClass += " error");
    return /*#__PURE__*/(
      React.createElement("form", { className: formClass, onSubmit: this.handleSubmit }, /*#__PURE__*/
      React.createElement("fieldset", { className: "form-group" }, /*#__PURE__*/
      React.createElement(ReactLabel, { htmlFor: "formName", title: "Username:" }), /*#__PURE__*/
      React.createElement("input", {
        id: "formName",
        className: "form-input",
        name: "username",
        type: "text" })), /*#__PURE__*/
      React.createElement("fieldset", { className: "form-group" }, /*#__PURE__*/
      React.createElement(ReactLabel, { htmlFor: "formPassword", title: "Password:" }), /*#__PURE__*/
      React.createElement("input", {
        id: "formPassword",
        ref: "myInput",
        className: "form-input",
        name: "password",
        type: "text" })),
      !this.state.valid && /*#__PURE__*/React.createElement("p", { className: "alert-danger" }, "Please try again"), /*#__PURE__*/
      React.createElement("input", {
        id: "formButton",
        className: "btn btn-primary",
        type: "submit",
        placeholder: "Send message" })));
  }}
const Success = () => /*#__PURE__*/
React.createElement("h2", null, "Thank you!");
ReactDOM.render( /*#__PURE__*/
React.createElement(HashRouter, null, /*#__PURE__*/
React.createElement(App, null)),
document.getElementById('root'));
</script>

</body>
</html>
Preview