content logo

React Forms:

React Contact us Massage Form

You can use this code to contact us on your website. This code has prepared a beautiful form for receiving user comments by using React. The comment button in this form is red. Each text field selected changes its color from gray to red. The background of this form is white and this form is responsive.

#

React Massaging Form

#

Contact us Form Code

#

HTML Contact us Form

#

Send Massage Form Code

<!-- 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>
                                                                            
*, *:before, *:after {
	box-sizing: border-box;
}
body {
	font: 400 16px Montserrat, sans-serif;
	color: #444;
	padding: 0;
	margin: 0;
	background-color: #f8f8f8;
}
.container {
	display: flex;
	min-height: 100vh;
	align-items: center;
	justify-content: center;
}
.card {
	width: 600px;
	background-color: #fff;
	border-radius: 3px;
	box-shadow: 0 2px 10px rgba(17, 34, 68, 0.06);
	overflow: hidden;
}
.waves {
	height: 80px;
	background: linear-gradient(to bottom left, #e14, #e72);
}
h1 {
	margin: 2rem 2rem 0;
	font-size: 1.62rem;
}
.form {
	padding: 2rem;
}
.button {
	display: block;
	width: 100%;
	background-color: #e14;
	border: none;
	border-radius: 3px;
	padding: 1ch;
	font-size: 1rem;
	color: #fff;
	font-family: inherit;
}
.text-input {
	position: relative;
	margin-bottom: 1rem;
}
.text-input label {
	position: absolute;
	top: 1ch;
	left: 1ch;
	padding: 0 0.5ch;
	pointer-events: none;
	transition: 150ms ease;
	color: #888;
}
.text-input label.label-focus {
	position: absolute;
	top: 0;
	font-size: 0.9em;
	color: #e14;
	font-weight: bold;
	transform: translateY(-50%);
	background-color: #fff;
	font-weight: 600;
}
.text-input input {
	display: block;
	width: 100%;
	border: 2px solid #eee;
	padding: 1ch;
	border-radius: 3px;
	transition: 150ms ease;
	outline: none;
	font-size: 1rem;
	font-family: inherit;
}
.text-input input.input-focus {
	border-color: #e14;
}
.text-area {
	position: relative;
	margin-bottom: 1rem;
}
.text-area label {
	position: absolute;
	top: 1ch;
	left: 1ch;
	padding: 0 0.5ch;
	pointer-events: none;
	transition: 150ms ease;
	color: #888;
}
.text-area label.label-focus {
	position: absolute;
	top: 0;
	font-size: 0.9em;
	color: #e14;
	font-weight: bold;
	transform: translateY(-50%);
	background-color: #fff;
	font-weight: 600;
}
.text-area textarea {
	display: block;
	width: 100%;
	border: 2px solid #eee;
	padding: 1ch;
	border-radius: 3px;
	transition: 150ms ease;
	outline: none;
	font-size: 1rem;
	font-family: inherit;
	height: 8em;
}
.text-area textarea.input-focus {
	border-color: #e14;
}
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } /** Components */
const Card = (props) => /*#__PURE__*/
    React.createElement("div", { className: "card" },
        props.children);
const Form = (props) => /*#__PURE__*/
    React.createElement("form", { className: "form" }, props.children);
const TextInput = (props) => /*#__PURE__*/
    React.createElement("div", {
        className: "text-input"
    }, /*#__PURE__*/
        React.createElement("label", {
            className: props.focus || props.value !== '' ? 'label-focus' : '',
            htmlFor: props.name
        }, props.label), /*#__PURE__*/
        React.createElement("input", {
            className: props.focus || props.value !== '' ? 'input-focus' : '',
            type: "text",
            name: props.name,
            value: props.value,
            onChange: props.onChange,
            onInput: props.onInput,
            onFocus: props.onFocus,
            onBlur: props.onBlur
        }));
const TextArea = (props) => /*#__PURE__*/
    React.createElement("div", {
        className: "text-area"
    }, /*#__PURE__*/
        React.createElement("label", {
            className: props.focus || props.value !== '' ? 'label-focus' : '',
            htmlFor: props.name
        }, props.label), /*#__PURE__*/
        React.createElement("textarea", {
            className: props.focus || props.value !== '' ? 'input-focus' : '',
            name: props.name,
            value: props.value,
            onChange: props.onChange,
            onInput: props.onInput,
            onFocus: props.onFocus,
            onBlur: props.onBlur
        }));
const Button = (props) => /*#__PURE__*/
    React.createElement("button", {
        className: "button"
    }, props.children);
/** Root Component */
class App extends React.Component {
    constructor() {
        super();
        this.state = {
            name: {
                name: 'name',
                label: 'Name',
                value: '',
                focus: false
            },
            email: {
                name: 'email',
                label: 'Email',
                value: '',
                focus: false
            },
            message: {
                name: 'message',
                label: 'Message',
                value: '',
                focus: false
            }
        };
    }
    handleFocus(e) {
        const name = e.target.name;
        const state = Object.assign({}, this.state[name]);
        state.focus = true;
        this.setState({ [name]: state }, () => { console.log(state); });
    }
    handleBlur(e) {
        const name = e.target.name;
        const state = Object.assign({}, this.state[name]);
        state.focus = false;
        this.setState({ [name]: state }, () => { console.log(state); });
    }
    handleChange(e) {
        const name = e.target.name;
        const state = Object.assign({}, this.state[name]);
        state.value = e.target.value;
        this.setState({ [name]: state }, () => { console.log(state); });
    }
    render() {
        const { name, email, message } = this.state;
        return /*#__PURE__*/(
            React.createElement("div", { className: "container" }, /*#__PURE__*/
                React.createElement(Card, null, /*#__PURE__*/
                    React.createElement("h1", null, "Send us a Message!"), /*#__PURE__*/
                    React.createElement(Form, null, /*#__PURE__*/
                        React.createElement(TextInput, _extends({},
                            name, {
                            onFocus: this.handleFocus.bind(this),
                            onBlur: this.handleBlur.bind(this),
                            onChange: this.handleChange.bind(this)
                        })), /*#__PURE__*/
                        React.createElement(TextInput, _extends({},
                            email, {
                            onFocus: this.handleFocus.bind(this),
                            onBlur: this.handleBlur.bind(this),
                            onChange: this.handleChange.bind(this)
                        })), /*#__PURE__*/
                        React.createElement(TextArea, _extends({},
                            message, {
                            onFocus: this.handleFocus.bind(this),
                            onBlur: this.handleBlur.bind(this),
                            onChange: this.handleChange.bind(this)
                        })), /*#__PURE__*/
                        React.createElement(Button, null, "Send")))));
    }
}
ReactDOM.render( /*#__PURE__*/React.createElement(App, null), document.getElementById('app'));
<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Montserrat:400,600'>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js'></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- This script got from frontendfreecode.com -->

<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Montserrat:400,600'>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js'></script>
<style>
*, *:before, *:after {
	box-sizing: border-box;
}
body {
	font: 400 16px Montserrat, sans-serif;
	color: #444;
	padding: 0;
	margin: 0;
	background-color: #f8f8f8;
}
.container {
	display: flex;
	min-height: 100vh;
	align-items: center;
	justify-content: center;
}
.card {
	width: 600px;
	background-color: #fff;
	border-radius: 3px;
	box-shadow: 0 2px 10px rgba(17, 34, 68, 0.06);
	overflow: hidden;
}
.waves {
	height: 80px;
	background: linear-gradient(to bottom left, #e14, #e72);
}
h1 {
	margin: 2rem 2rem 0;
	font-size: 1.62rem;
}
.form {
	padding: 2rem;
}
.button {
	display: block;
	width: 100%;
	background-color: #e14;
	border: none;
	border-radius: 3px;
	padding: 1ch;
	font-size: 1rem;
	color: #fff;
	font-family: inherit;
}
.text-input {
	position: relative;
	margin-bottom: 1rem;
}
.text-input label {
	position: absolute;
	top: 1ch;
	left: 1ch;
	padding: 0 0.5ch;
	pointer-events: none;
	transition: 150ms ease;
	color: #888;
}
.text-input label.label-focus {
	position: absolute;
	top: 0;
	font-size: 0.9em;
	color: #e14;
	font-weight: bold;
	transform: translateY(-50%);
	background-color: #fff;
	font-weight: 600;
}
.text-input input {
	display: block;
	width: 100%;
	border: 2px solid #eee;
	padding: 1ch;
	border-radius: 3px;
	transition: 150ms ease;
	outline: none;
	font-size: 1rem;
	font-family: inherit;
}
.text-input input.input-focus {
	border-color: #e14;
}
.text-area {
	position: relative;
	margin-bottom: 1rem;
}
.text-area label {
	position: absolute;
	top: 1ch;
	left: 1ch;
	padding: 0 0.5ch;
	pointer-events: none;
	transition: 150ms ease;
	color: #888;
}
.text-area label.label-focus {
	position: absolute;
	top: 0;
	font-size: 0.9em;
	color: #e14;
	font-weight: bold;
	transform: translateY(-50%);
	background-color: #fff;
	font-weight: 600;
}
.text-area textarea {
	display: block;
	width: 100%;
	border: 2px solid #eee;
	padding: 1ch;
	border-radius: 3px;
	transition: 150ms ease;
	outline: none;
	font-size: 1rem;
	font-family: inherit;
	height: 8em;
}
.text-area textarea.input-focus {
	border-color: #e14;
}
</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>
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } /** Components */
const Card = (props) => /*#__PURE__*/
    React.createElement("div", { className: "card" },
        props.children);
const Form = (props) => /*#__PURE__*/
    React.createElement("form", { className: "form" }, props.children);
const TextInput = (props) => /*#__PURE__*/
    React.createElement("div", {
        className: "text-input"
    }, /*#__PURE__*/
        React.createElement("label", {
            className: props.focus || props.value !== '' ? 'label-focus' : '',
            htmlFor: props.name
        }, props.label), /*#__PURE__*/
        React.createElement("input", {
            className: props.focus || props.value !== '' ? 'input-focus' : '',
            type: "text",
            name: props.name,
            value: props.value,
            onChange: props.onChange,
            onInput: props.onInput,
            onFocus: props.onFocus,
            onBlur: props.onBlur
        }));
const TextArea = (props) => /*#__PURE__*/
    React.createElement("div", {
        className: "text-area"
    }, /*#__PURE__*/
        React.createElement("label", {
            className: props.focus || props.value !== '' ? 'label-focus' : '',
            htmlFor: props.name
        }, props.label), /*#__PURE__*/
        React.createElement("textarea", {
            className: props.focus || props.value !== '' ? 'input-focus' : '',
            name: props.name,
            value: props.value,
            onChange: props.onChange,
            onInput: props.onInput,
            onFocus: props.onFocus,
            onBlur: props.onBlur
        }));
const Button = (props) => /*#__PURE__*/
    React.createElement("button", {
        className: "button"
    }, props.children);
/** Root Component */
class App extends React.Component {
    constructor() {
        super();
        this.state = {
            name: {
                name: 'name',
                label: 'Name',
                value: '',
                focus: false
            },
            email: {
                name: 'email',
                label: 'Email',
                value: '',
                focus: false
            },
            message: {
                name: 'message',
                label: 'Message',
                value: '',
                focus: false
            }
        };
    }
    handleFocus(e) {
        const name = e.target.name;
        const state = Object.assign({}, this.state[name]);
        state.focus = true;
        this.setState({ [name]: state }, () => { console.log(state); });
    }
    handleBlur(e) {
        const name = e.target.name;
        const state = Object.assign({}, this.state[name]);
        state.focus = false;
        this.setState({ [name]: state }, () => { console.log(state); });
    }
    handleChange(e) {
        const name = e.target.name;
        const state = Object.assign({}, this.state[name]);
        state.value = e.target.value;
        this.setState({ [name]: state }, () => { console.log(state); });
    }
    render() {
        const { name, email, message } = this.state;
        return /*#__PURE__*/(
            React.createElement("div", { className: "container" }, /*#__PURE__*/
                React.createElement(Card, null, /*#__PURE__*/
                    React.createElement("h1", null, "Send us a Message!"), /*#__PURE__*/
                    React.createElement(Form, null, /*#__PURE__*/
                        React.createElement(TextInput, _extends({},
                            name, {
                            onFocus: this.handleFocus.bind(this),
                            onBlur: this.handleBlur.bind(this),
                            onChange: this.handleChange.bind(this)
                        })), /*#__PURE__*/
                        React.createElement(TextInput, _extends({},
                            email, {
                            onFocus: this.handleFocus.bind(this),
                            onBlur: this.handleBlur.bind(this),
                            onChange: this.handleChange.bind(this)
                        })), /*#__PURE__*/
                        React.createElement(TextArea, _extends({},
                            message, {
                            onFocus: this.handleFocus.bind(this),
                            onBlur: this.handleBlur.bind(this),
                            onChange: this.handleChange.bind(this)
                        })), /*#__PURE__*/
                        React.createElement(Button, null, "Send")))));
    }
}
ReactDOM.render( /*#__PURE__*/React.createElement(App, null), document.getElementById('app'));
</script>

</body>
</html>
Preview