React Progress UI Component

4.0.0 · active · verified Sun Apr 19

rc-progress is a lightweight, performant React UI component library providing fundamental progress indicators, specifically Line and Circle progress bars. It is currently stable at version 4.0.0, released in late 2023, with maintenance releases occurring periodically as needed. The library focuses on delivering unstyled, highly customizable SVG-based progress components, allowing developers full control over styling and animation via props like `strokeWidth`, `strokeColor`, and `percent`. It differentiates itself by offering a lean API for common progress scenarios without the overhead of a full UI component suite. The library ships with TypeScript type definitions, ensuring a robust development experience, and maintains compatibility with modern React versions (>=16.9.0) while also supporting older browsers like IE9+.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use both `Line` and `Circle` components with a dynamically updating percentage, illustrating basic usage and styling.

import React, { useState, useEffect } from 'react';
import { Line, Circle } from 'rc-progress';

const ProgressDemo: React.FC = () => {
  const [percent, setPercent] = useState<number>(0);

  useEffect(() => {
    const timer = setInterval(() => {
      setPercent((prevPercent) => {
        if (prevPercent >= 100) {
          return 0; // Reset progress
        }
        return prevPercent + 10;
      });
    }, 500);

    return () => clearInterval(timer);
  }, []);

  return (
    <div style={{ padding: '20px', maxWidth: '400px', margin: 'auto', textAlign: 'center' }}>
      <h2>Line Progress</h2>
      <Line
        percent={percent}
        strokeWidth={4}
        strokeColor={percent > 50 ? '#87d068' : '#108ee9'}
        trailWidth={4}
        style={{ marginBottom: '40px' }}
      />

      <h2>Circle Progress</h2>
      <Circle
        percent={percent}
        strokeWidth={6}
        strokeColor={percent > 50 ? '#87d068' : '#108ee9'}
        trailWidth={6}
        strokeLinecap="round"
        style={{ width: '150px', height: '150px' }}
      />

      <p style={{ marginTop: '30px', fontSize: '1.2em', fontWeight: 'bold' }}>
        Current Progress: {percent}%
      </p>
    </div>
  );
};

export default ProgressDemo;

view raw JSON →