content logo

React Progress Bars:

React Progress Bar with Color Change

In this post, we have put one of the most efficient progress bars for free. This is the React Progress Bar with Color Change that has a lot of potential to increase the beauty of your website. If you provide a service on your website, this HTML Progress Bar can show the time that users have to wait to access their needed services. On the other hand, it is better to choose a beautiful theme to attract people’s attention. This Colorful Progress Bar is so attractive and is suitable for happy websites.

This Responsive React Progress Bar has a white background and the title has a large font in black color. There is a gray field in this post and you can see a white button at the bottom of the field. This button has a black border. After clicking on this button, you will face attractive changes. The gray field starts moving from the left to the right side with a colorful theme. Its color also changes with a beautiful effect. The first color of this Progress Bar with Percentage is red and then turns green. If you are looking for an attractive bootstrap, this code is a great idea.

#

Colorful Progress Bar

#

HTML Progress Bar

#

Progress Bar with Percentage

#

Responsive React Progress Bar

<!-- This script got from frontendfreecode.com -->
<h1>JavaScript Progress Bar</h1>
<div id="myProgress">
</div>
<br>
<button onclick="move()">Click Me</button><a style="font-size: 8pt; text-decoration: none" target="_blank" href="http://frontendfreecode.com">Free Frontend</a>
                                                                            
#myProgress {
  position: relative;
  width: 100%;
  height: 30px;
  background-color: #ddd;
}
#myBar {
  position: absolute;
  width: 10%;
  height: 100%;
  background-color: #4CAF50;
}
#label {
  text-align: center;
  line-height: 30px;
  color: white;
}
class Progressbar extends React.Component {
  constructor() {
    super();
    this.state = {
      progress: 0,
      speed: 1,
      color: "#ff0050" };
    this.frame = this.frame.bind(this);
    this.green = this.green.bind(this);
    this.red = this.red.bind(this);
  }
  componentDidMount() {
    console.clear();
    this.interval = setInterval(() => this.frame(), 100);
  }
  frame() {
    if (this.state.progress < 100) {
      this.setState((prevState, props) => ({
        progress: prevState.progress + this.state.speed,
        color: "#" + this.red() + this.green() + "50" }));
      console.log(this.state.color);
    }
  }
  componentWillUnmount() {
    clearInterval(this.interval);
  }
  green() {
    let progress = this.state.progress;
    progress *= 2.55;
    progress = Math.round(progress);
    progress = progress.toString(16);
    return progress;
  }
  red() {
    let progress = this.state.progress;
    progress *= 2.55;
    progress = Math.round(progress);
    progress = 255 - progress;
    progress = progress.toString(16);
    return progress;
  }
  render() {
    return /*#__PURE__*/(
      React.createElement("div", { id: "myBar", style: {
          width: this.state.progress + "%",
          backgroundColor: this.state.color } }, /*#__PURE__*/
      React.createElement("div", { id: "label" }, "Loaded ", this.state.progress, "%")));
  }}
function move() {
  ReactDOM.render( /*#__PURE__*/
  React.createElement(Progressbar, null),
  document.getElementById('myProgress'));
}
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.3.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.3.1/react.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react-dom.min.js'></script>
<style>
#myProgress {
  position: relative;
  width: 100%;
  height: 30px;
  background-color: #ddd;
}
#myBar {
  position: absolute;
  width: 10%;
  height: 100%;
  background-color: #4CAF50;
}
#label {
  text-align: center;
  line-height: 30px;
  color: white;
}
</style>

</head>
<body>
<h1>JavaScript Progress Bar</h1>
<div id="myProgress">
</div>
<br>
<button onclick="move()">Click Me</button><div id="bcl"><a style="font-size:8pt;text-decoration:none;" href="http://www.devanswer.com">Free Frontend</a></div>
<script>
class Progressbar extends React.Component {
  constructor() {
    super();
    this.state = {
      progress: 0,
      speed: 1,
      color: "#ff0050" };
    this.frame = this.frame.bind(this);
    this.green = this.green.bind(this);
    this.red = this.red.bind(this);
  }
  componentDidMount() {
    console.clear();
    this.interval = setInterval(() => this.frame(), 100);
  }
  frame() {
    if (this.state.progress < 100) {
      this.setState((prevState, props) => ({
        progress: prevState.progress + this.state.speed,
        color: "#" + this.red() + this.green() + "50" }));
      console.log(this.state.color);
    }
  }
  componentWillUnmount() {
    clearInterval(this.interval);
  }
  green() {
    let progress = this.state.progress;
    progress *= 2.55;
    progress = Math.round(progress);
    progress = progress.toString(16);
    return progress;
  }
  red() {
    let progress = this.state.progress;
    progress *= 2.55;
    progress = Math.round(progress);
    progress = 255 - progress;
    progress = progress.toString(16);
    return progress;
  }
  render() {
    return /*#__PURE__*/(
      React.createElement("div", { id: "myBar", style: {
          width: this.state.progress + "%",
          backgroundColor: this.state.color } }, /*#__PURE__*/
      React.createElement("div", { id: "label" }, "Loaded ", this.state.progress, "%")));
  }}
function move() {
  ReactDOM.render( /*#__PURE__*/
  React.createElement(Progressbar, null),
  document.getElementById('myProgress'));
}
</script>

</body>
</html>
Preview