Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

225
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda