Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

269
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda