You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<divclass="flex flex-col gap-4 m-10 [--color-red:255_0_0]"><divclass="h-10 w-80 bg-red-500">1. classic</div><divclass="h-10 w-80 bg-[#f00]">2. custom color</div><divclass="h-10 w-80 bg-[rgb(var(--color-red))]">3. custom color from var</div><divclass="h-10 w-80 bg-[rgb(var(--broken-var,var(--color-red)))]">4. custom color from var with fallback</div><divclass="h-10 w-80 bg-[rgb(var(--color-red))]/50">5. custom color from var with opacity</div><divclass="h-10 w-80 bg-[rgb(var(--broken-var,var(--color-red)))]/50">6. custom color from var with fallback and with opacity</div><divclass="h-10 w-80 bg-[rgb(var(--broken-var,var(--color-red))/0.5)]">7. custom color from var with fallback and with "manual" opacity</div></div>
It seems tailwind is unable to properly process such syntax: bg-[rgb(var(--broken-var,var(--color-red)))]/50. There's no output at all. The reason for this is most likely CSS variable being nested for fallback value.
For nested var() without opacity modifier: bg-[rgb(var(--broken-var,var(--color-red)))] the output is correct:
The only reasonable workaround I found is to "manually" apply alpha value to rgb() function like so: bg-[rgb(var(--broken-var,var(--color-red))/0.5)], which gives an output that I would expect to get for the broken example:
Hey, thanks for reporting this one. We weren't handling the case of a variable with a variable fallback when we had to parse the color (which we do when using an opacity modifier).
I've merged the fix in #12049 and it'll be available in our next release. In the meantime you'll be able to test it via our insiders build once it's built and published on NPM (takes like 10m I think):
What version of Tailwind CSS are you using?
version: 3.3.3
What build tool (or framework if it abstracts the build tool) are you using?
play.tailwindcss.com
What version of Node.js are you using?
browser
What browser are you using?
chrome
What operating system are you using?
macOs
Reproduction URL
https://play.tailwindcss.com/djB8sJngwG
Describe your issue
Full example code:
It seems tailwind is unable to properly process such syntax:
bg-[rgb(var(--broken-var,var(--color-red)))]/50
. There's no output at all. The reason for this is most likely CSS variable being nested for fallback value.For nested
var()
without opacity modifier:bg-[rgb(var(--broken-var,var(--color-red)))]
the output is correct:The only reasonable workaround I found is to "manually" apply alpha value to
rgb()
function like so:bg-[rgb(var(--broken-var,var(--color-red))/0.5)]
, which gives an output that I would expect to get for the broken example:However, I think it would be great to be able to use consistent syntax across all use-cases.
The text was updated successfully, but these errors were encountered: