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

160
Views
Programatically generate nth-child CSS rules and apply them on element REACT

Hi a wanted to generate dynamic CSS rules based on the props comes in the REACT component. I get an array as props and i want to generate nth-child css rules based on the length of the props. For example:

while (marks[i] && marks[i].direction !== 's') {
    const rule = {
      selector: `.item:nth-child(${2 * length}n + ${length + 1 + i})`,
      styles: `grid-column:${length - i};`,
    };
    arr.push(rule);
    i++;
  }

Where marks is the props array comes in and the length is the length of the marks array. It generates the CSS rules, but how can i apply them on the component.

OR any other solutions for this?

about 4 years ago · Juan Pablo Isaza
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!