content logo

React Buttons:

Various React Buttons with Custom Effects and Movements

You can use this code to compare the features of a button. This code implements a style for a few buttons by adding or subtracting one of its features. One of the buttons is completely simple. One button is inactive and the other button has a motion effect. All of these buttons are made using React.

#

Free React Button Code

#

Animating React Button

#

Stylish HTML Button Code

#

React Button Examples

<!-- 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";
body {
	margin: 0;
	background: linear-gradient(0deg, #050A0F, #131C28);
}
ul li {
	color: steelblue;
	padding: 15px;
}
.shake {
	-webkit-animation-name: shake;
	animation-name: shake;
	-webkit-animation-duration: 1s;
	animation-duration: 1s;
	-webkit-animation-iteration-count: infinite;
	animation-iteration-count: infinite;
}
@-webkit-keyframes shake {
	0% {
		transform: translateX(-2px);
	}
	100% {
		transform: translateX(2px);
	}
}
@keyframes shake {
	0% {
		transform: translateX(-2px);
	}
	100% {
		transform: translateX(2px);
	}
}
.button {
	position: relative;
	display: inline-block;
	margin: 0;
	padding: 0;
	width: auto;
	font-weight: inherit;
	font-size: inherit;
	line-height: 1;
	letter-spacing: normal;
	text-align: center;
	text-decoration: none;
	border: none;
	border-radius: 4px;
	box-sizing: border-box;
	cursor: pointer;
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
	transition: background-color 0.3s ease;
}
.button_medium {
	padding: 11px 20px;
	/* height 40px */
	font-weight: 600;
	font-size: 16px;
}
.button_large {
	padding: 15px 20px;
	/* 50px */
	font-weight: 600;
	font-size: 18px;
}
.button_accent {
	color: #D6DDE8;
	background-color: #3AB176;
}
.button_accent:hover {
	background-color: #40CD87;
}
.button_accent:focus {
	background-color: #2B935F;
	box-shadow: inset 0 1px 3px 0 rgba(0, 0, 0, 0.4);
}
.button_accent-invert {
	color: #3AB176;
	background-color: #FFFFFF;
}
.button_disabled, .button [disabled] {
	color: #FFFFFF;
	background-color: #CCCCCC;
	pointer-events: none;
}
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);}const Button = function () {/* имитация импорта */
  const mainClass = 'button';
  const sizeClasses = {
    'medium': 'button_medium',
    'large': 'button_large' };
  const colorClasses = {
    'accent': 'button_accent',
    'accent-invert': 'button_accent-invert' };
  return function Button(props) {
    const Tag = props.href ? 'a' : 'button';
    const classNameArr = [];
    classNameArr.push(mainClass);
    classNameArr.push(sizeClasses[props.size] || '');
    classNameArr.push(colorClasses[props.color] || '');
    classNameArr.push(props.className || ''); /* пользовательский класс */
    /* удаялем лишние атрибуты */
    delete props.size;
    delete props.color;
    return /*#__PURE__*/(
      React.createElement(Tag, _extends({}, props, { className: classNameArr.join(' ') }),
      props.children));
  };
}();
class App extends React.Component {
  render() {
    return /*#__PURE__*/(
      React.createElement("ul", null, /*#__PURE__*/
      React.createElement("li", null, /*#__PURE__*/
      React.createElement(Button, null, "Button (no parameters)")), /*#__PURE__*/
      React.createElement("li", null, /*#__PURE__*/
      React.createElement(Button, { size: "medium", color: "accent" }, "Button")), /*#__PURE__*/
      React.createElement("li", null, /*#__PURE__*/
      React.createElement(Button, { href: "#", size: "medium", color: "accent-invert" }, "Button (link)")), /*#__PURE__*/
      React.createElement("li", null, /*#__PURE__*/
      React.createElement(Button, { className: "shake", size: "large", color: "accent" }, "Button (with custom class)")), /*#__PURE__*/
      React.createElement("li", null, /*#__PURE__*/
      React.createElement(Button, { size: "medium", disabled: true }, "Button (disabled)")), /*#__PURE__*/
      React.createElement("li", null, /*#__PURE__*/
      React.createElement(Button, { size: "medium", color: "accent", onClick: function () {alert('click!');} }, " We can send any props"))));
  }}
ReactDOM.render( /*#__PURE__*/React.createElement(App, null), document.getElementById("app"));
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/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/normalize/5.0.0/normalize.min.css">
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react-dom.min.js'></script>
<style>
@charset "UTF-8";
body {
	margin: 0;
	background: linear-gradient(0deg, #050A0F, #131C28);
}
ul li {
	color: steelblue;
	padding: 15px;
}
.shake {
	-webkit-animation-name: shake;
	animation-name: shake;
	-webkit-animation-duration: 1s;
	animation-duration: 1s;
	-webkit-animation-iteration-count: infinite;
	animation-iteration-count: infinite;
}
@-webkit-keyframes shake {
	0% {
		transform: translateX(-2px);
	}
	100% {
		transform: translateX(2px);
	}
}
@keyframes shake {
	0% {
		transform: translateX(-2px);
	}
	100% {
		transform: translateX(2px);
	}
}
.button {
	position: relative;
	display: inline-block;
	margin: 0;
	padding: 0;
	width: auto;
	font-weight: inherit;
	font-size: inherit;
	line-height: 1;
	letter-spacing: normal;
	text-align: center;
	text-decoration: none;
	border: none;
	border-radius: 4px;
	box-sizing: border-box;
	cursor: pointer;
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
	transition: background-color 0.3s ease;
}
.button_medium {
	padding: 11px 20px;
	/* height 40px */
	font-weight: 600;
	font-size: 16px;
}
.button_large {
	padding: 15px 20px;
	/* 50px */
	font-weight: 600;
	font-size: 18px;
}
.button_accent {
	color: #D6DDE8;
	background-color: #3AB176;
}
.button_accent:hover {
	background-color: #40CD87;
}
.button_accent:focus {
	background-color: #2B935F;
	box-shadow: inset 0 1px 3px 0 rgba(0, 0, 0, 0.4);
}
.button_accent-invert {
	color: #3AB176;
	background-color: #FFFFFF;
}
.button_disabled, .button [disabled] {
	color: #FFFFFF;
	background-color: #CCCCCC;
	pointer-events: none;
}
</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);}const Button = function () {/* имитация импорта */
  const mainClass = 'button';
  const sizeClasses = {
    'medium': 'button_medium',
    'large': 'button_large' };
  const colorClasses = {
    'accent': 'button_accent',
    'accent-invert': 'button_accent-invert' };
  return function Button(props) {
    const Tag = props.href ? 'a' : 'button';
    const classNameArr = [];
    classNameArr.push(mainClass);
    classNameArr.push(sizeClasses[props.size] || '');
    classNameArr.push(colorClasses[props.color] || '');
    classNameArr.push(props.className || ''); /* пользовательский класс */
    /* удаялем лишние атрибуты */
    delete props.size;
    delete props.color;
    return /*#__PURE__*/(
      React.createElement(Tag, _extends({}, props, { className: classNameArr.join(' ') }),
      props.children));
  };
}();
class App extends React.Component {
  render() {
    return /*#__PURE__*/(
      React.createElement("ul", null, /*#__PURE__*/
      React.createElement("li", null, /*#__PURE__*/
      React.createElement(Button, null, "Button (no parameters)")), /*#__PURE__*/
      React.createElement("li", null, /*#__PURE__*/
      React.createElement(Button, { size: "medium", color: "accent" }, "Button")), /*#__PURE__*/
      React.createElement("li", null, /*#__PURE__*/
      React.createElement(Button, { href: "#", size: "medium", color: "accent-invert" }, "Button (link)")), /*#__PURE__*/
      React.createElement("li", null, /*#__PURE__*/
      React.createElement(Button, { className: "shake", size: "large", color: "accent" }, "Button (with custom class)")), /*#__PURE__*/
      React.createElement("li", null, /*#__PURE__*/
      React.createElement(Button, { size: "medium", disabled: true }, "Button (disabled)")), /*#__PURE__*/
      React.createElement("li", null, /*#__PURE__*/
      React.createElement(Button, { size: "medium", color: "accent", onClick: function () {alert('click!');} }, " We can send any props"))));
  }}
ReactDOM.render( /*#__PURE__*/React.createElement(App, null), document.getElementById("app"));
</script>

</body>
</html>
Preview