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

273
Views
Extending Material UI theme via Module Augmentation not working

I'm trying to add an "input" property to the background field within palette and then augment the Theme to account for types, like so:

export const lightTheme = createTheme(commonTheme, {
  palette: {
    mode: 'light',
    background: {
     default: '#FFFFFF',
     input: '#0000BB',
      ...
}
declare module '@mui/material/styles' {
  interface Theme {
    background: {
      input: React.CSSProperties['color'];
    };
  }

  interface ThemeOptions {
    background: {
      input: React.CSSProperties['color'];
    };
  }
}

However, when I try to access background via color: theme.palette.background.input, i get an error:

Property 'input' does not exist on type 'TypeBackground'.

Why is augmentation not adding the type to the background property?

To add, I also tried this which didn't change anything:

declare module "@mui/material/styles/createPalette" {
  interface CommonColors {
    background: {
      input: React.CSSProperties['color'];
    }
  }
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You just need to extend the type TypeBackground as shown below:

declare module '@mui/material/styles' {
   interface TypeBackground {
        input: string;
    }
}

and then configure a new value for background.input

const theme = createTheme({
  ....
  palette: {
    background: {
      input: "#f60"
    }
  }
 ...
});

Finally, we can use it like this:

<Box sx={{ bgcolor: "background.input", width: 100, height: 100 }} />

The demo link

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!