[Tailwind 3.1.2] Gradient issue: `to-[color]-[number]` is not displayed even if specified
See original GitHub issue[Tailwind v3.1.2, React v18.1.0, Node v17.0.1, Chrome, Windows]
I copied the example described here and pasted it onto my main (and only) css file. Apparently in version 3.1.2 “via-[color]-[number]” causes a conflict with “to-[color]-[number]”.
When “via-…-…” is added, the gradient shows only the “from-…-…” color and the “via-…-…” color, even if the “to-…-…” color is specified.
(My project has only one css file (screenshot below) and the other styles I apply are inline-classes, but I’ve tried removing them and it doesn’t solve the issue)
Main issue
:
index.css
:
Chrome devtools
:
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Issue with tailwind css gradient - Stack Overflow
It looks like there is no color schema in your config. Just add this to your tailwind.config.js.
Read more >Content Configuration - Tailwind CSS
Configuring source paths. Tailwind CSS works by scanning all of your HTML, JavaScript components, and any other template files for class names, ...
Read more >A guide to adding gradients with Tailwind CSS - LogRocket Blog
In this blog, we'll use Tailwind CSS to create beautiful background, text, border, and underline gradients, as well as animate gradients.
Read more >Background Colors & Gradients In Tailwind - YouTube
This video will learn you how to use background colors and gradient background colors in Tailwind. Besides, I'll show you how to apply ......
Read more >CSS class completion doesn't work great with Tailwind 2.1 in ...
Preview (if it is correct version) still does NOT solve the problem ? TailwindCSS plugin still does not show any completion on blade...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah that sucks. CRA continues to be a major source of pain for us because of how opinionated it is around PostCSS 😕 Going to close this as not our issue then, but would highly discourage using CRA. Use Vite instead, it an amazing environment for client-side React apps like CRA is, but with a much smoother experience especially with Tailwind 👍
No worries! Thanks! I think I figured out the issue here. The
@supports
rule is coming from thecreate-react-app
stack. My local test env was just following the tailwind docs with React. After ejecting cra and tinkering around, I found the issue goes away whenpostcss-preset-env
is removed.Simplified, Tailwind outputs the
--tw-gradient-to
property multiple times.produces this:
Then if
postcss-preset-env
is involved, it transforms the above to……and that causes the color to reset to the other value.
Technically, nothing wrong with the Tailwind CSS output. It looks like an edge case bug in how
postcss-preset-env
protectsrgb
colors with slash syntax. They should probably just ignore properties that get redeclared in a different syntax.That being said, it could be fixed on the Tailwind side if the custom property was only output once.