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

230
Vistas
React sharing behavior of external CSS file - body background for components

how can I change React sharing behavior of an external CSS file in React, so I can set the body background different for different components?

login.css

body {
  background-image: url('../../../images/bannerbackground.png');
}

home.css

body {
  background-color: rgb(185, 174, 160);
}

but for react's sharing behavior with the components of the same root I cannot differentiate it, is there any solution?

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

0

Yes there is a solution. Its pretty simple. To prevent the clashes you can implement CSS modules. Rename your CSS files to filename.module.css

Result:

// note the classname generated 
<button class="Button_error_ax7yz">Error Button</button>

According to the official repo CSS Modules are “CSS files in which all class names and animation names are scoped locally by default”. What does this mean? CSS Modules are not specs or an implementation in the browser, but rather a process in a build step (with the help of Webpack or Browserify) that changes class names and selectors to be scoped (kinda like namespaced)

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