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

268
Views
React MUI: Button group color change on the selected button

i have a buttongroup from Material UI, and the code is here

  const [currentProjectSelect, setCurrentProjectSelect] = useState(null);

This is my state.

        <ButtonGroup size="small" className={classes.projectTypeButton}>
         {projectType === 'offPlatform' && projectTypeValues.map((element, index) =>
          <Button 
            key={element.value}
            variant="contained" 
            color="primary"
            className={[classes.budgetButton, {backgroundColor: currentProjectSelect === index ? '#315FFF' : '#fff'}]}
            onClick={() => {
              if (currentProjectSelect === null){
                form.budget_type = element.value
                setCurrentProjectSelect(element.name)
              }
              else {
                setCurrentProjectSelect(null)
              }
            }
            }
          >{element.name}</Button>
        )}
      </ButtonGroup>

Here in the className I am trying to implement a logic where selected button will have different background color. It is not working. I used to be react native developer and the same logic used to work in styles.

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!