A circular progress indicator component built with React and SVG
npx @tessl/cli install tessl/npm-react-circular-progressbar@2.2.0React Circular Progressbar is a highly customizable circular progress indicator component built with React and SVG. It offers extensive theming capabilities through CSS and inline styles, supports arbitrary content placement within the progressbar, and provides features like custom value ranges, rotation options, stroke width customization, and animation controls.
npm install react-circular-progressbarimport { CircularProgressbar } from 'react-circular-progressbar';
import 'react-circular-progressbar/dist/styles.css';With children support:
import { CircularProgressbarWithChildren } from 'react-circular-progressbar';
import 'react-circular-progressbar/dist/styles.css';For style customization:
import { CircularProgressbar, buildStyles } from 'react-circular-progressbar';
import 'react-circular-progressbar/dist/styles.css';import React from 'react';
import { CircularProgressbar } from 'react-circular-progressbar';
import 'react-circular-progressbar/dist/styles.css';
function App() {
const percentage = 66;
return (
<div style={{ width: 200, height: 200 }}>
<CircularProgressbar value={percentage} text={`${percentage}%`} />
</div>
);
}React Circular Progressbar is built around several key components:
Type System Architecture:
The component's type system is designed around inheritance for flexibility:
value propertyvalue)children propertyThis design allows the main component to have comprehensive defaults while wrapper components remain flexible.
Primary circular progressbar component with extensive customization options for displaying progress values from 0-100 or custom ranges.
interface CircularProgressbarProps extends CircularProgressbarDefaultProps {
value: number;
}
interface CircularProgressbarDefaultProps {
background: boolean;
backgroundPadding: number;
circleRatio: number;
classes: {
root: string;
trail: string;
path: string;
text: string;
background: string;
};
className: string;
counterClockwise: boolean;
maxValue: number;
minValue: number;
strokeWidth: number;
styles: CircularProgressbarStyles;
text: string;
}
interface CircularProgressbarStyles {
root?: React.CSSProperties;
trail?: React.CSSProperties;
path?: React.CSSProperties;
text?: React.CSSProperties;
background?: React.CSSProperties;
}Wrapper component that allows placing arbitrary JSX content inside the progressbar with automatic centering and responsive sizing.
interface CircularProgressbarWithChildrenProps extends CircularProgressbarWrapperProps {
children?: React.ReactNode;
}
interface CircularProgressbarWrapperProps {
value: number;
background?: boolean;
backgroundPadding?: number;
circleRatio?: number;
classes?: {
root: string;
trail: string;
path: string;
text: string;
background: string;
};
className?: string;
counterClockwise?: boolean;
maxValue?: number;
minValue?: number;
strokeWidth?: number;
styles?: CircularProgressbarStyles;
text?: string;
}Utility function for generating comprehensive style objects with common customization options like colors, transitions, and rotations.
function buildStyles(options: {
rotation?: number;
strokeLinecap?: any;
textColor?: string;
textSize?: string | number;
pathColor?: string;
pathTransition?: string;
pathTransitionDuration?: number;
trailColor?: string;
backgroundColor?: string;
}): CircularProgressbarStyles;