Here is my code using Tailwind and classnames library:
import React from 'react';
import cn from 'classnames';
function Navbar({
left,
title,
right,
bgColor = 'primary-800',
textColor,
sticky = true,
}) {
return (
<div
className={cn({
[`bg-${bgColor}`]: true,
[`text-${textColor}`]: true,
['sticky top-0']: sticky,
['z-10 flex h-11 items-center px-4 py-5 font-semibold shadow']: true,
})}
>
<div className="h-5 w-5 flex-none">{left}</div>
<div className="grow text-center">
<span>{title}</span>
</div>
<div className="h-5 w-5 flex-none"> {right}</div>
</div>
);
}
export default Navbar;
When I deploy the code, the generated CSS file does not contain bg color property.
class="bg-primary-800 text-white z-10 flex h-11 items-center px-4 py-5 font-semibold shadow sticky top-0"
There is no problem with the class.
Is it because tailwind is purging the unused classnames?