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

308
Views
Is there a way that we can use attribute selectors in Material-UI using makeStyles?

I am trying to extract all the div's having some specific Mui classenames say access-MuiPickersCalendarHeader-switchHeader,access-MuiPickersDay-day etc. Here the actual class names are MuiPickersCalendarHeader-switchHeader,MuiPickersDay-day as per Material-ui. As I am seeding my components using StylesProvider it is adding access infront of the classes as prefix. Is there anyway that i can fetch all the div's whose class names includes "MuiPickersDay-day","MuiPickersCalendarHeader-switchHeader" and style them using makeStyles in material-ui?

For Example: Component 1 is having some elements with classnames : aboutpage-MuiPickersDay-day Component 2 is having some elements with classnames : homepage-MuiPickersDay-day

Create a makeStyles where i can style both of the component's elements whose classname includes 'MuiPickersDay-day'

I have tried using attribute selectors in makeStyles but i am not able to do that. It is not allowing me to use that approach For eample:

const useStyles = makeStyles((theme) => createStyles({
               div[class^='MuiPickersDay-day]:{backgroundColor:'black'}
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Solution Found:

In createStyles object do this:

const useStyles = makeStyles((theme) => createStyles({
               '*':{
                     '& [class*="MuiPickersDay-day"]':{
                               backgroundColor:'black'
                        }
} });

In this way not only can you just target div rather you can apply styles for all the elements which consist of 'MuiPickersDay-day' class. if you want you can also give multiple class names like: [class*="MuiPaper-root"][class*="MuiPopover-paper"][class*="MuiPaper-rounded"]

Happy Coding!!

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!