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

214
Views
Spreading a global theme to another theme in MUI (Material UI)

I am using MUI's ThemeProvider and have created a Themes.js file. In that file, I have defined globalTheme for my global styles like type and border-radius. I want to spread globalTheme it to lightTheme and darkTheme. This works in CodeSandbox but not VSCode. When I save I get an error "TypeError: Invalid attempt to spread non-iterable instance" see the image below.

enter image description here

import { createTheme } from "@mui/material";


// global theme styles
const globalTheme = createTheme({
  typography: {
    fontFamily: "'Inter', sans-serif",
    body1: {
      fontSize: "1.25rem",
    },
  },
});





   export const lightTheme = createTheme(
...globalTheme,
  {
    palette: {
      mode: "light",
      // primrary brand color
      primary: {
        main: "#b9431d",
      },
      // secondary brand color
      secondary: {
        main: "#0074aa",
      },
      text: {
        // text colors
        primary: "rgba(32, 26, 24, 1)",
        secondary: "rgba(32, 26, 24, .8)",
        disabled: "rgba(32, 26, 24, .38)",
      },

      background: {
        default: "#F9F2ED",
      },
    },
    // overrides for components
    components: {
      MuiTooltip: {
        styleOverrides: {
          tooltip: {
            color: "white",
            backgroundColor: "black",
          },
          arrow: {
            color: "black",
          },
        },
      },
    },
  },
);

// dark theme styles
export const darkTheme = createTheme(
...globalTheme,

  {
    palette: {
      mode: "dark",
      text: {
        // text colors
        primary: "rgba(237, 224, 220, 1)",
        secondary: "rgba(237, 224, 220, .8)",
        disabled: "rgba(237, 224, 220, .38)",
      },
      // primary brand color
      primary: {
        main: "#ffb59f",
      },
      // secondary brand color
      secondary: {
        main: "#7fd2ec",
      },
      background: {
        default: "#201a18",
        paper: "#201a18",
      },
    },
    // overrides for components
    components: {
      MuiTooltip: {
        styleOverrides: {
          tooltip: {
            color: "black",
            backgroundColor: "white",
          },
          arrow: {
            color: "white",
          },
        },
      },
    },
  },

);

about 4 years ago · Juan Pablo Isaza
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!