This repository demonstrates a subtle bug in Tailwind CSS's gradient utility classes. When defining a linear gradient using the bg-gradient-to-*
utilities, omitting the second (or subsequent) color results in unexpected behavior. Instead of throwing an error or warning, Tailwind silently defaults to the first color, rendering a solid color instead of a gradient.
bug.js
and examine the code.div
element intended to have a gradient background only shows a solid blue color.bugSolution.js
to see a corrected version that uses a proper gradient definition.Always ensure that you provide at least two colors when defining a gradient with Tailwind. If you intend to have a single color, use the standard background color utilities.