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

162
Views
Adding path to an image in CSS module from public folder in react

I am trying to add an image as background, however the location of image is in a pulic folder. -public -images -image.png -src -assets -components -index.tsx -index.module.css (I want to use the image.png in this file)

If I put the image in src/assets, I can use it as background: url(./assets/image.png). I can also access it in index.tsx. However, I am trying to access the image in module.css from the public folder as I need to change the image on hover.

.up {
  /*path in source works*/
  background: url(../../../../assets/keyboardKeys/keyboardArrows.png) 150px 51px;   

  /*path outside source. inside public. I want to use this */
  background: url(Assets/keyboardKeys/keyboardArrows.png) 150px 51px; 
}

Using the second url results in the following error:

Failed to compile.

./src/app/index.module.css (./node_modules/css-loader/dist/cjs.js??ref--5-oneOf-5-1!./node_modules/postcss-loader/src??postcss!./src/app/index.module.css)
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

you can use file inside public folder directly

background: url(folderInPublic/image.png)
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!