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

332
Views
MUI Custom named options in palette - Property 'primary' does not exist on type 'TypeBackground'

I am trying to extend the MUI palette so I can use my own named properties with the following code:

declare module '@mui/material/styles' {
  interface Palette {
    border: Palette['primary']
    background: Palette['primary']
  }

  // allow configuration using `createTheme`
  interface PaletteOptions {
    border?: PaletteOptions['primary']
    background?: PaletteOptions['primary']
  }
}

border works without issues, however since trying to add a new background it does complain about this one.

Full Error:

Property 'primary' does not exist on type 'TypeBackground'.  TS2339

     8 | 
     9 | const DocumentUploadContainer = styled('div')`
  > 10 |   color: ${props => props.theme.palette.background.primary};
       |                                                    ^
    11 | `
    12 | export const Documents = () => {
    13 |   return (

enter image description here

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

0

You can check in file createPalette.d.ts of mui. Because background is already in interface PaletteOptions, (as you can see here)

export interface PaletteOptions {
  primary?: PaletteColorOptions;
  secondary?: PaletteColorOptions;
  error?: PaletteColorOptions;
  warning?: PaletteColorOptions;
  info?: PaletteColorOptions;
  success?: PaletteColorOptions;
  mode?: PaletteMode;
  tonalOffset?: PaletteTonalOffset;
  contrastThreshold?: number;
  common?: Partial<CommonColors>;
  grey?: ColorPartial;
  text?: Partial<TypeText>;
  divider?: string;
  action?: Partial<TypeAction>;
  background?: Partial<TypeBackground>;
  getContrastText?: (background: string) => string;
}
export interface TypeBackground {
  default: string;
  paper: string;
}

Hence, you cannot use module augmentation to override it like this. Just use another name.

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!