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

203
Views
How to get each element inside a map and change its CSS?

I want to loop through and assign a custom CSS property to each element inside a map called "item", but I don't know how to do that. Below is my code:

import React from "react";

// Splitting Letters
const SplitText = React.memo(({ str }) => {
  

  const customStyle = {
    position: "absolute",
    /*top: some random top value,*/
    /*left: some random left value,*/
    zIndex: "initial",
    color: "green"
  };

  return (
    <div>
      {str.split("").map((item, index) => {

        
        return (
          <div key={index}>
            {item}
          </div>
        );
      })}
    </div>
  );
});

export default SplitText;

My "item" has a set of letters and I want to catch hold of each letter and somehow map the customStyle CSS property to it.

Any suggestions would be of great help.

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

0

return them with your customStyle


  const customStyle = [{
    position: "absolute",
    /*top: some random top value,*/
    /*left: some random left value,*/
    zIndex: "initial",
    color: "green"
  },{
    position: "relative",
    /*top: some random top value,*/
    /*left: some random left value,*/
    zIndex: "1",
    color: "red"
  }];

 return (
          <div key={index} style={customStyle[index]}>
            {item}
          </div>
        );
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!