• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

295
Views
How to replace space with   in a string (ReactJS) and render in HTML?
<div className="mt-2 font-sidebar capitalize">
  {item.title}
</div>

item.title can be any string (from backend) for example "all products", "most liked", "featured items", etc.

I want a way to replace the space in item.title with &nbsp; so that when rendered in HTML it still has a space - This is for a specific use case.

I would really appreciate your help.

about 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can do like this:

{item.title.replaceAll(' ', '\u00a0')};

you can use replace() if you are sure there is only 1 space, so i suggest to use replaceAll()

Instead of using the &nbsp; you can use the Unicode character which &nbsp; refers to (U+00A0):

about 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error