Next.js Discord

Discord Forum

Colours are not displayed

Unanswered
Mike posted this in #help-forum
Open in Discord
Hello everyone. I have the following code. This code creates a chip which should be displayed in a table. For each specific rank the chip should be displayed in a specific colour. The classes are also added correctly which I have tested with the Chrome Developer Tools. But unfortunately no background colour is displayed. or only specific ones.

import React from "react";
import { ranks } from "@/utils/ranksdata";
import { Chip } from "@nextui-org/react";

const RankDisplay = ({ rank }) => {
  return (
    <Chip
      key={rank}
      className={`${getRankColor(rank)} text-white font-bold capitalize`}
      size="sm"
      variant="flat"
    >
      {rank}
    </Chip>
  );
};

function getRankColor(rankValue) {
  const rank = ranks.find((r) => r.value === rankValue);
  return rank ? rank.color : "bg-default-500";
}

export default RankDisplay;

2 Replies

If I do not pass the background colour dynamically, but simply pass the class directly, all the colours are of course displayed in the correct colour. but unfortunately it does not work dynamically
I have fixed it with tailwindcss purging