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

226
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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