Next.js Discord

Discord Forum

My divs are white ?

Answered
Barbary Lion posted this in #help-forum
Open in Discord
Barbary LionOP
I'm currenty working on a personal project.

In localhost everything's fine but with vercel, my div are white...?

How can i fix this ?

Repo : https://github.com/bastianfbr/next-quiz
Site : https://nquiz.vercel.app/
Answered by Ray
const colorMap = {
  "red": "bg-red-500"
  "orange": "bg-orange-500"
}

<div className={`flex flex-col items-center justify-center rounded-md p-8 mb-2 w-2/4 sm:w-80 mx-auto ${colorMap[color]}`}>

something like this
View full answer

9 Replies

<div className={`flex flex-col items-center justify-center rounded-md p-8 mb-2 w-2/4 sm:w-80 mx-auto bg-${color}-500`}>
the color class cannot be dynamic
@Ray the color class cannot be dynamic
Barbary LionOP
but it works in localhost...
try npm run build and npm run start
it won't work
tailwind doc has mention it
Barbary LionOP
ah...
so what can i do ?
const colorMap = {
  "red": "bg-red-500"
  "orange": "bg-orange-500"
}

<div className={`flex flex-col items-center justify-center rounded-md p-8 mb-2 w-2/4 sm:w-80 mx-auto ${colorMap[color]}`}>

something like this
Answer