React Suite is a popular front-end library with a set of React components that are designed for the middle platform and back-end products. Progress is used to indicate user task is completed or at what stage it is currently on. There are two types of progress provided.
- Line: Line progress shows a line UI which can be horizontal or vertical.
- Circular: Circular progress shows a circle UI which indicates data in percentage.
They both have different props for the user to indicate their task’s progress accordingly.
<Progress.Line> Props:
- classPrefix: ‘progress’ denote the prefix of the component CSS class.
- percent: The percentage of the line progress is shown through this.
- showInfo: It is used to specify whether the text will be shown or not in line progress.
- status: ‘success’, ‘fail’, and ‘active’ denotes line progress status.
- strokeColor: It is used to specify the color of the line progress.
- strokeWidth: It is used to specify the line width of the line progress.
- vertical: It is used to specify if line progress is vertical or not.
<Progress.Circle> Props:
- classPrefix: ‘progress’ denote the prefix of the component CSS class.
- gapDegree: Gap Degree of the half-circle range from 0 to 360
- gapPosition: ‘right’ , ‘top’ , ‘bottom’ , ‘left’ denotes notch position.
- percent: The percentage of the circular progress is shown through this.
- showInfo: It is used to specify whether the text will be shown or not in circular progress.
- status: ‘success’, ‘fail’ and ‘active’ denotes circular progress status.
- strokeColor: It is used to specify the color of the circular progress.
- strokeWidth: It is used to specify the line width of the circular progress.
- strokeLineCap: ’round’, ‘square’, and ‘butt’ denotes the end of open paths.
- trailColor: It is used to specify the color of the circular progress trail.
- trailWidth: It is used to specify the trail width of the circular progress.
Approach: Let us create a React project and install React Suite module. Then we will create a UI that will showcase React Suite Progress Props.
Creating React Project:
Step 1: To create a react app, you need to install react modules through npx command. “npx” is used instead of “npm” because you will be needing this command in your app’s lifecycle only once.
npx create-react-app project_name
Step 2: After creating your react project, move into the folder to perform different operations.
cd project_name
Step 3: After creating the ReactJS application, Install the required module using the following command:
npm install rsuite
Project Structure: After running the commands mentioned in the above steps, if you open the project in an editor you can see a similar project structure as shown below. The new component user makes or the code changes, we will be performing will be done in the source folder.
Example 1: We are creating a UI that shows different React Suite Vertical Line Progress with vertical prop.
App.js
import React from "react" ; import { Progress } from 'rsuite' ; import '../node_modules/rsuite/dist/rsuite.min.css' ; class App extends React.Component { render() { return ( <div style={{textAlign: "center" ,margin:30}}> <h3 style={{color: "green" }}>Geeks for Geeks</h3> <h6>React Suite Vertical Line Progress</h6><br /> <Progress.Line vertical percent={50} strokeColor= "yellow" /> </div> ); } } |
Step to Run Application: Run the application using the following command from the root directory of the project:
npm start
Output: Now open your browser and go to http://localhost:3000/, you will see the following output.
Example 2: We are creating a UI that shows different React Suite Circle Progress using progress.circle string class prefix and its different props.
App.js
import React from "react" ; import { Progress } from 'rsuite' ; import '../node_modules/rsuite/dist/rsuite.min.css' ; const myStyle = { width: 120, display: 'inline-block' , marginRight: 10 }; class App extends React.Component { render() { return ( <div style={{margin:100}}> <h3 style={{color: "green" }}>Geeks for Geeks</h3> <h6>React Suite Circular Progress</h6><br /> <div style={myStyle}> <Progress.Circle percent={60} strokeColor= "green" strokeWidth={5} trailWidth={5} trailColor= "blue" /></div> <div style={myStyle}> <Progress.Circle percent={80} strokeColor= "yellow" strokeWidth={3} trailWidth={3} trailColor= "orange" /></div> </div> ); } } export default App; |
Output: Now open your browser and go to http://localhost:3000/, you will see the following output:
Reference: https://rsuitejs.com/components/progress/#props