Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

223
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda