Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

361
Views
How to map over array of colors for a datatable in React?

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.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!