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

246
Vistas
Spread theme in sx prop MUI 5

The previous code, which used v4, was

const useStyles = makeStyles(theme => ({
  toolbarMargin: {
    ...theme.mixins.toolbar
  }
}))

How to migrate this code to MUI v5 using sx prop, I tried using it like this

<Box
  sx={{
    ...(theme) => theme.mixins.toolbar,
  }}
/>

but the theme was not defined.

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

You can do the following:

<Box sx={theme => theme.mixins.toolbar} />

or

<Box sx={theme => ({
  ...theme.mixins.toolbar,
  // other sx stuff
})} />

As you can also pass a function with theme as parameter to the sx prop, it must return valid sx object.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Using styled() is probably less convoluted.

const Container = styled('div')(theme => theme.mixins.toolbar)
about 4 years ago · Juan Pablo Isaza Denunciar

0

For me most of the solutions above resulted in an non fatal error, as sx accepts object, not functions. This worked:

<Box
sx={{
    "&": (theme) => theme["whateverYouWishToSpread"]
}}
>{someStuff}</Box>
about 4 years ago · Juan Pablo Isaza Denunciar
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