content logo

React Buttons:

React Expanding Button with Color Change on Hover

You can use effects for hover and click mode to make your system interactive. In this code, we have created a hawthorn effect for a button using React. This button on the border is black and gray. By placing the mouse on it, the button expands slightly and its color becomes pink.

#

Dynamic React Button Code

#

HTML Expanding Button Code

#

React Color Change Effect

#

React Button Dynamic Size

<!-- 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>
                                                                            
body {
  background: #b3cce6;
  display: flex;
  justify-content: center;
  align-items: center;
}
button {
  margin: 30px auto;
  width: 100px;
  height: 50px;
  border-radius: 5px;
  transition: all 0.5s ease-out;
}
button:hover {
  width: 150px;
  transition: 0.5s;
  max-width: 100% !important;
  background-color: #ff3399;
  font-weight: bold;
}
class App extends React.Component {
  render() {
    return /*#__PURE__*/React.createElement(Button, null, "I ", /*#__PURE__*/React.createElement(Heart, null), " React");
  }}
const Button = props => /*#__PURE__*/React.createElement("button", null, props.children);
class Heart extends React.Component {
  render() {
    return /*#__PURE__*/React.createElement("span", null, "\u2665");
  }}
ReactDOM.render( /*#__PURE__*/
React.createElement(App, null),
document.getElementById('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>
body {
  background: #b3cce6;
  display: flex;
  justify-content: center;
  align-items: center;
}
button {
  margin: 30px auto;
  width: 100px;
  height: 50px;
  border-radius: 5px;
  transition: all 0.5s ease-out;
}
button:hover {
  width: 150px;
  transition: 0.5s;
  max-width: 100% !important;
  background-color: #ff3399;
  font-weight: bold;
}
</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 {
  render() {
    return /*#__PURE__*/React.createElement(Button, null, "I ", /*#__PURE__*/React.createElement(Heart, null), " React");
  }}
const Button = props => /*#__PURE__*/React.createElement("button", null, props.children);
class Heart extends React.Component {
  render() {
    return /*#__PURE__*/React.createElement("span", null, "\u2665");
  }}
ReactDOM.render( /*#__PURE__*/
React.createElement(App, null),
document.getElementById('root'));
</script>

</body>
</html>
Preview