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

196
Views
MUI React Theme palette contrastText doesn't work

I'm using MUI React to create a menu and I used the AppBar component. I want to customize in this way:

brown.myBrown = '#544846';
const brownTheme = createTheme({
    palette: {
        primary: {
            main: brown.myBrown,
            contrastText: grey[50]
        }
    }
});

The contrastText field doesn't work and the result is a brown appBar with also text color brown as show here:

Screenshot of AppBar component The menu items are visibile only when I hover on them.

How can I change the item color in grey[50]?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The value of contrastText only gets applied if you set the color property as follows in your AppBar component:

<AppBar color={'primary'}>

(Or to 'secondary' if you want to use the corresponding contrastText value.)

If you don't want to set that property you can also use this approach:

const theme = useTheme();
...
<AppBar [...] sx={{color: theme.palette.primary.contrastText}}>

color doesn't set the background-color but the color of descendants.

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!