create card using array of data react

hi everyone I have data given below by using this data I just want to create a cart click on this link to check what kind of cart I want to design from this data

 const result = [
{
  name: 'shanu',
  label: ['ak', 'pk', 'plk', 'k'],
  value: [1, 2, 3, 5],
},

];

// what i did

 {result.map((el) => {
        return (
          <div>
            <h1>{el.name}</h1>
            <div className="vart">
              <div>
                {el.label.map((e) => {
                  return <p>{e}</p>;
                })}
              </div>
              <div>
                {el.value.map((e) => {
                  return <p>{e}</p>;
                })}
              </div>
            </div>
          </div>
        );
      })}
.vart {
  display: flex;
  flex-direction: row;
}

Solution 1:

You can access the value according to the index of the label as below. You can use a CSS grid system to show a two-column view.

export default function App() {
  const result = [
    {
      name: "shanu",
      label: ["ak", "pk", "plk", "k"],
      value: [1, 2, 3, 5]
    }
  ];

  return result.map((el) => {
    return (
      <div>
        <div className="header">{el.name}</div>
        <div className="grid-container">
          {el.label.map((e, index) => {
            return (
              <div
                className="grid-item"
                style={{ textAlign: index % 2 === 0 ? "left" : "right" }}
              >
                {e} : {el.value[index]}
              </div>
            );
          })}
        </div>
      </div>
    );
  });
}

Following styles will organise the grid with right aligning the second column.

.header {
  color: #ffffff;
  background-color: #4473c4;
  padding: 10px 20px;
}

.grid-container {
  display: grid;
  grid-template-columns: auto auto;
}

.grid-item {
  padding: 10px 20px;
  color: #ffffff;
  background-color: #91cf50;
}

HTML Output

enter image description here

Code Sandbox