Repository navigation
Description
What versions are you using? (if relevant)
react-email@6.11.17 (latest, with tailwindcss 4.3.5). Same on canary at e1c0044.
Describe the Bug
Shadows with an opacity don't get the plain rgb() other colors get, and Gmail (web and Android) then removes the element's whole style attribute: padding, border, background and text color all go.
<Tailwind>
<div className="shadow-lg shadow-red-500/40">Opacity on the color</div>
<div className="shadow-lg/20">Opacity on the shadow</div>
<div className="shadow-lg shadow-[#ff000080]">Alpha color</div>
<div className="bg-[#ff000080]/50">Alpha color, opacity</div>
</Tailwind>gives these colors:
color-mix(in oklab,rgb(251,44,54,0.4) 100%,transparent)
oklab(from rgb(0,0,0,0.1) l a b/20%)
rgb(255,0,0,0.5019607843137255,100%)
background-color:rgb(255,0,0,0.5019607843137255,0.5)
shadow-red-500/40nests onecolor-mix()in another and only the inner one is converted (fix(react-email): resolve theme variables used inside Tailwind utility variables #3803 listed it as not addressed);shadow-lg/20writes its color asoklab(from …), which nothing converts.- An alpha color gets a second alpha; five values are invalid, so the shadow and background disappear in every browser (
text-andborder-too). - Every colored shadow ends in a percentage alpha (
shadow-red-500givesrgb(251,44,54,100%)), which fix(tailwind): convert color-mix opacity percentage to a decimal alpha #3579 changed to decimals for backgrounds and text but not for shadows.
Gmail, with plain rgb() copies on the right:
Cause: the color-mix() conversion expects a bare rgb() without an alpha, and reaches the outer color-mix() before the inner one is converted. For shadows the percentage is still var(--tw-shadow-alpha) there, filled in later with its registered 100% or the element's own value.
bg-current/40 also leaves a color-mix() that Gmail strips, but it has no rgb() form; not part of this.
I have a fix with tests and will open a PR.
AI disclosure: found and drafted with Claude's help. I reproduced it on 6.11.17 and on canary and checked it in Gmail and in Chromium, WebKit and Firefox.
What is affected (leave empty if unsure)
Tailwind Component
Link to the code that reproduces this issue
No separate repo needed: the snippet above, with import { render, Tailwind } from 'react-email' and console.log(await render(...)).
To Reproduce
- In an empty folder,
npm install react-email@6.11.17 react react-dom. - Render the snippet and print the HTML (with
npx tsx, set"jsx": "react-jsx"in tsconfig.json). - Look at the
styleattributes, or send the HTML to Gmail.
Expected Behavior
A plain rgb() with a decimal alpha, as bg-red-500/40 gets, in the colors browsers compute from Tailwind's CSS: rgb(251,44,54,0.4), rgb(0,0,0,0.2), rgb(255,0,0,0.502) and a rgb(255,0,0,0.251) background. Gmail then keeps the other styles.
What's your node version? (if relevant)
v24.12.0
Activity