Currently, I am developing a web application with Next.JS and Tailwind CSS for styling. In this project, I need to map over some "accords" related to perfumes and assign variable widths to each one based on the size
property of the accord
, which is a string. To achieve this, I am dynamically generating Tailwind classes for each div as follows:
className={`text-center w-${accord.size} rounded-r-2xl`}
In addition to assigning widths, I also have a style property that sets the background color based on the data associated with each accord:
style={{ backgroundColor: accordsData[accord.accord].color }}
The issue I'm facing is that when the code renders in the browser, it automatically adds width: 0px;
to the style attribute, causing the width not to display correctly:
<div class="text-center w-100 rounded-r-2xl" style="background-color: rgb(204, 51, 0); width: 0px;">...</div>
I'm looking for a solution where my application does not append this extra style and instead utilizes the width specified in the Tailwind class. Your assistance on this matter would be greatly appreciated.