So I have the following styling:
function Button({
children,
primary,
secondary,
success,
warning,
danger,
outline,
rounded,
}) {
const classes = className("flex items-center px-3 py-1.5 border", {
"border-blue-500 bg-blue-500 text-white": primary,
"border-gray-900 bg-gray-900 text-white": secondary,
"border-green-500 bg-green-500 text-white": success,
"border-yellow-400 bg-yellow-400 text-white": warning,
"border-red-500 bg-red-500 text-white": danger,
"rounded-full": rounded,
"bg-white": outline,
"text-blue-500": outline && primary,
"text-gray-500": outline && secondary,
"text-green-500": outline && success,
"text-yellow-400": outline && warning,
"text-red-500": outline && danger,
});
return <button className={classes}>{children}</button>;
}
In Tailwind the last styles listed override the text color and the purpose of that is so if a button is outline
then we do not want a text color of white because the background is white in an outline button, so we want the color of the text to change if the button is designated as outline
. That is the purpose of the last four lines of classes, but it no longer works ever since I installed react-icons
.
By no longer working I mean the "text-white" remains where outline
is applied.
Now, I am wondering if the Button.propTypes
solution is what clobbering it:
Button.propTypes = {
checkVariationValue: ({ primary, secondary, success, warning, danger }) => {
const count =
Number(!!primary) +
Number(!!secondary) +
Number(!!warning) +
Number(!!success) +
Number(!!danger);
if (count > 1) {
return new Error(
"Only one of primary, success, warning, danger can be true"
);
}
},
};