This repository demonstrates an uncommon bug encountered when using Tailwind CSS. The hover effect on buttons is overridden by a parent div's background color, specifically under certain color conditions. This bug only appears on certain color palettes.
A button with hover styles applied using Tailwind CSS classes does not show the expected hover effect when the parent div has a particular background color. The parent div's background seems to override the button's hover styles.
npm install
npm start
The solution is to apply !important
to the relevant hover styles to force them to override the parent div styles. Refer to bugSolution.js for code samples demonstrating this fix.
This bug highlights the importance of understanding CSS specificity and how parent styles can unintentionally override child styles. Using !important
is generally not recommended, so exploring alternative layout structures and selector specificity is best practice. The root cause of this behavior warrants further investigation into Tailwind's internal CSS generation.