A React component for visualizing milestone or status-based progress as a color-coded gradient bar. Ideal for showing how many tasks are completed, in-progress, incomplete, or any other category you define. Written in TypeScript and fully tested with Jest + React Testing Library.
- Color-coded gradient that segments based on the proportion of each status.
- Optional counts displayed at segment midpoints.
- Highly customizable with props for height, colors, and layout.
- TypeScript definitions included.
- Works seamlessly with styled-components or your own CSS approach.
npm install milestone-progress-barOr with yarn:
yarn add milestone-progress-barHere’s a quick example of how to import and use the MilestoneProgressBar in your React app:
import React from 'react';
import { MilestoneProgressBar } from 'milestone-progress-bar';
const ExampleComponent = () => {
const statuses = [
{ count: 5, color: '#4CAF50', label: 'Completed' },
{ count: 3, color: '#FFC107', label: 'In Progress' },
{ count: 2, color: '#F44336', label: 'Incomplete' },
];
return (
<div style={{ width: '300px' }}>
<h2>Project Status</h2>
<MilestoneProgressBar
statuses={statuses}
height="6px"
showCounts={true}
/>
</div>
);
};
export default ExampleComponent;| Prop | Type | Default | Description |
|---|---|---|---|
statuses |
IMilestoneStatus[] |
[] |
Array of milestone status objects. Each contains count (number) and color (string) fields. |
height |
string |
"4px" |
Height of the gradient bar. |
showCounts |
boolean |
true |
Whether to display the numeric counts above each segment. |
style |
React.CSSProperties |
undefined |
Optional styles applied to the parent container. |
className |
string |
undefined |
Optional class name for styling overrides. |
The IMilestoneStatus interface is defined as:
interface IMilestoneStatus {
count: number;
color: string;
label?: string; // optional text label
}This package is tested with Jest + React Testing Library. To run tests locally:
npm test- Clone this repository.
- Run
npm install. - Run
npm run buildto compile the TypeScript intodist/. - Run
npm testto ensure all tests pass.
Feel free to use, modify, and distribute this package as per the license terms.