Skip to content

Tailwind: opacity on shadows inlines color-mix() or oklab(), and Gmail then drops the element's whole style #3950

Backlog

Description

@Maliik-B

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)

Gmail, with plain rgb() copies on the right:

gmail-issue-cropped

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

  1. In an empty folder, npm install react-email@6.11.17 react react-dom.
  2. Render the snippet and print the HTML (with npx tsx, set "jsx": "react-jsx" in tsconfig.json).
  3. Look at the style attributes, 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions