Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

228
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!