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

187
Views
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 answers
Answer question

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 Report
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!