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

153
Vistas
How to use material ui sx props with a styles object?

I have a styles object that would look like this:

styles = {
  color: "#333",
  fontSize: "16px",
};

I could apply styles to a Material UI component like below and it would work.

<Button sx={styles}>Example</Button>;

However, what if the Button component already had custom styles? How would I push my styles object then? For example, in this case:

<Button
  sx={{
    backgroundColor: "red",
    fontWeight: "700",
  }}
>
  Example
</Button>;

How would I add the styles object without overwriting the sx prop?

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

0

You could use the Spread syntax, like below. If you wanna know more about it, you can read on MDN's documentation.

What it's doing, in my words, is that it removes styles object's {}, and add it into the final object.

styles = {
  color: "#333",
  fontSize: "16px",
};
<Button
  sx={{
    backgroundColor: "red",
    fontWeight: "700",
    ...styles,
  }}
>
  Example
</Button>
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