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

189
Vistas
how to specify which filter is selected - react - material ui

i am making a blog with filter, the filtering just works fine but I want to specify which the filter is selected..

the code is

{cardCategories.map((cat) => {
  return (
    <Chip
      key={cat}
      style={{ margin: "5px 5px 25px 5px" }}
      label={cat}
      variant='outlined'
      clickable
      id={cat}
      onClick={handleCategoryChange}
    />
  );
})}

this show the following

enter image description here

when clicked one of these button the filtered posts are shown below this but we can't figure out which category is selected. This chip component is made with material-ui.

I want to apply styling on the clicked button so that is shows which of the categories is selected. If I apply styling with

document.getElementById("All").style.border = "1px solid red"

then it is applied but when clicked on the 2nd category it then shows styling on the both and so it does not remove the border from the previous but applies on all the clicked ones.

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

 {cardCategories.map((cat) => {
        return (
          <Chip
            key={cat}
            style={{ margin: "5px 5px 25px 5px" }}
            className={cat === currentCategory ? classes.selectedCAT : null}
            label={cat}
            variant='outlined'
            clickable
            id={cat}
            onClick={handleCategoryChange}
          />
        );
      })}

By Adding className styling worked fine

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