I'm using material ui table to map over data from API but each table row has a progress bar. I want to be able to give the progress bar different colors. Here's the code below...
const BorderLinearProgress = withStyles((theme) => ({
bar: {
borderRadius: 5,
backgroundColor: "red"
},
}))(LinearProgress);
export default function FeatureTwo() {
const [hmoName, setHmoName] = useState([]);
const [hmoProgress, setHmoProgress] = useState([]);
const getHmo = async () => {
try {
//API call
} catch (err) {
console.log(err);
}
};
return (
<Table aria-label="customized table">
<TableHead>
<TableRow>
<StyledTableCell align="left">HMO</StyledTableCell>
<StyledTableCell align="left">Enrollment Progress{''} (Percent %)</StyledTableCell>
</TableRow>
</TableHead>
<TableBody>
<TableRow>
<TableCell align="left" >
{hmoName.map((name, idx) => {
return (
<button key={idx}>
{name}
</button>
);
})}
</TableCell>
<TableCell align="left" >
<div>
{hmoProgress.map((number, idx) => {
return (
<div>
<div>
<span key={idx}>
{parseInt(number).toFixed(0)}
</span>
<span >
Progress
</span>
</div>
<span>
<BorderLinearProgress
variant="determinate"
value={parseInt(number).toFixed(0)}
/>
</span>
</div>
);
})}
</div>
</TableCell>
</TableRow>
</TableBody>
</Table>
);
}
BordeLineProgress has a background color set to red, all the progress bar in each row has the BC red. I want to set different colors for each progress bar for each row.