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

239
Views
How to change the border color of cards by checking the condition in react js

I have a variable that gets the value from the rest api in json format. The variable is data rate. The conditions are such that if the data rate is greater than 1MB it is said to be active and the border color should be green, if less than 1MB it is said to be inactive. Similarly there are few other conditions as well. How to change the border of the card automatically considering the value. So my question is how to add conditioning for the border color within the card tab.

  <Card className="cluster-cards" >
  <Card.Header as="h5">Cluster-1 [ID]</Card.Header>
  <Card.Body>
    <Card.Text>
      <Card border="dark" bg="light" style={{ width: '18rem' }} className ="sub-cards">
        <Card.Header>CAN 1</Card.Header>
          <Card.Body>
          <Card.Text>
            <h6><Badge pill bg="primary">Source ID-{783}</Badge></h6>  
            <h6><Badge pill bg="secondary">Data Rate-{'345Kbps'}</Badge></h6> 
            <h6><Badge pill bg="info">Total amount of data received-{'6MB'}</Badge></h6>   
          </Card.Text>
          </Card.Body>
      </Card>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can try this.

const customStyle = {
  borderColor: conditionState ? "#fff" : "red"
}
<Card className="cluster-cards" style={customStyle} >

//OR

<Card className="cluster-cards" className={${conditionState ? "border-none" : "border-red"}} >

about 4 years ago · Juan Pablo Isaza Report
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!