Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

271
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda