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

102
Views
Convert CSS to React.js Style

I am using Elementor as a REST Api and I am getting bunch of strings in React side in this shape :

selector a {
    width: 189px;
    line-height: 29px;
}

Is there any library that can convert CSS with Pseudo to inline style in React? I tried to use https://www.npmjs.com/package/style-to-js library but it doesn't support brackets and Pseudo

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

0

So if what you want to do is apply this styles when you receive the response, you can do something like this with vanilla JS

var styleTxt=".container {background-color:grey;color:orange;width:100px;} footer {heigth: 50px;background-color:black} button {color:white; font-size: 15px; border: 1px solid white; background: transparent}"

setTimeout(()=>{
  var element = document.createElement('style');
  element.setAttribute('type', 'text/css');
  element.innerHTML = styleTxt;
  document.head.append(element);
}, 2000)
<div class="container">
  <span>Test for dinamic css</span>
  <footer>
    <button>Test</button>
  </footer>
</div>

styleTxt will be the response of the call.

I just put the timeout so you can see the before and after :)

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!