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

188
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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