Next.js Discord

Discord Forum

My divs are white ?

Answered
Barbary Lion posted this in #help-forum
Open in Discord
Avatar
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/
Image
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

Avatar
Ray
<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
Avatar
Barbary LionOP
but it works in localhost...
Avatar
Ray
try npm run build and npm run start
it won't work
tailwind doc has mention it
Avatar
Barbary LionOP
ah...
so what can i do ?
Avatar
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
Answer