content logo

React Progress Bars:

React Tiny Progress Bar with Range Element

Using a progress bar can be great for attracting people and engaging older audiences. So, if you have a website and would like to attract more viewers, this React Tiny Progress Bar with the Range Element can be useful. With the help of this amazing Progress Bar Using React, you are able to represent your progression during a specific time. Additionally, the following Mini Progress Bar Code is mostly simple, and as a result, you can utilize it for different kinds of websites with various themes. So, we recommend you download this code freely and apply it to your website.

A preview of this beautiful code is located down so that you can realize its performance. When you pay attention to this preview, you can realize that the JavaScript Progress Bar Range has a black background with a simple design. There is a line in the corner of the page with white color. There is a field under this line that shows your preparation in percentile. As you progress, this line moves forward, and it changes to white. At the same time, the bottom field presents your progression with numbers in an orange square. Downloading and using this Colorful Progress Bar is all you need.

#

Mini Progress Bar Code

#

Colorful Progress Bar

#

Progress Bar using React

#

Javascript Progress Bar Range

<!-- 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>
                                                                            
body {
	background-color: #212123;
	color: #ffffff;
}
.bar {
	height: 30px;
	width: 122px;
	padding-left: 5px;
	padding-right: 5px;
	background-color: #404040;
	display: flex;
	align-items: center;
	justify-content: flex-start;
}
.fill {
	height: 20px;
	transition: background-color 1s ease;
}
.fill.ok {
	background-color: #4CAF50;
}
.fill.warning {
	background-color: #FF9800;
}
.fill.danger {
	background-color: #F44336;
}
.percentage {
	position: absolute;
	margin: 0;
	margin-left: 2px;
	font-family: sans;
	font-size: 0.8em;
}
class Progress extends React.Component {
  constructor() {
    super();
    this.state = { value: 25 };
  }
  getInitialState() {
    return {
      value: 25 };
  }
  setValue() {
    this.setState({ value: this.refs.range.value });
  }
  render() {
    return /*#__PURE__*/(
      React.createElement("div", { className: "react-progress-example" }, /*#__PURE__*/
      React.createElement("input", {
        ref: "range",
        type: "range",
        min: "0",
        max: "100",
        defaultValue: this.state.value,
        onChange: this.setValue.bind(this) }), /*#__PURE__*/
      React.createElement(ProgressBar, { current: this.state.value })));
  }}
;
class ProgressBar extends React.Component {
  constructor() {
    super();
    this.percentage = 25;
  }
  getPercentage() {
    this.percentage = this.props.current;
  }
  getStyle() {
    if (this.percentage <= 20) {
      this.style = "danger";
    } else
    if (this.percentage > 20 && this.percentage <= 50) {
      this.style = "warning";
    } else
    {
      this.style = "ok";
    }
  }
  render() {
    this.getPercentage();
    this.getStyle();
    return /*#__PURE__*/(
      React.createElement("div", { className: "bar" }, /*#__PURE__*/
      React.createElement("p", { className: "percentage" }, this.percentage, " "), /*#__PURE__*/
      React.createElement("div", { style: { width: this.percentage + "%" }, className: "fill " + this.style })));
  }}
ReactDOM.render( /*#__PURE__*/React.createElement(Progress, null), document.getElementById('app'));
<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>
body {
	background-color: #212123;
	color: #ffffff;
}
.bar {
	height: 30px;
	width: 122px;
	padding-left: 5px;
	padding-right: 5px;
	background-color: #404040;
	display: flex;
	align-items: center;
	justify-content: flex-start;
}
.fill {
	height: 20px;
	transition: background-color 1s ease;
}
.fill.ok {
	background-color: #4CAF50;
}
.fill.warning {
	background-color: #FF9800;
}
.fill.danger {
	background-color: #F44336;
}
.percentage {
	position: absolute;
	margin: 0;
	margin-left: 2px;
	font-family: sans;
	font-size: 0.8em;
}
</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>
class Progress extends React.Component {
  constructor() {
    super();
    this.state = { value: 25 };
  }
  getInitialState() {
    return {
      value: 25 };
  }
  setValue() {
    this.setState({ value: this.refs.range.value });
  }
  render() {
    return /*#__PURE__*/(
      React.createElement("div", { className: "react-progress-example" }, /*#__PURE__*/
      React.createElement("input", {
        ref: "range",
        type: "range",
        min: "0",
        max: "100",
        defaultValue: this.state.value,
        onChange: this.setValue.bind(this) }), /*#__PURE__*/
      React.createElement(ProgressBar, { current: this.state.value })));
  }}
;
class ProgressBar extends React.Component {
  constructor() {
    super();
    this.percentage = 25;
  }
  getPercentage() {
    this.percentage = this.props.current;
  }
  getStyle() {
    if (this.percentage <= 20) {
      this.style = "danger";
    } else
    if (this.percentage > 20 && this.percentage <= 50) {
      this.style = "warning";
    } else
    {
      this.style = "ok";
    }
  }
  render() {
    this.getPercentage();
    this.getStyle();
    return /*#__PURE__*/(
      React.createElement("div", { className: "bar" }, /*#__PURE__*/
      React.createElement("p", { className: "percentage" }, this.percentage, " "), /*#__PURE__*/
      React.createElement("div", { style: { width: this.percentage + "%" }, className: "fill " + this.style })));
  }}
ReactDOM.render( /*#__PURE__*/React.createElement(Progress, null), document.getElementById('app'));
</script>

</body>
</html>
Preview