Skip to content

TW4 @property breaks TW3 gradients used in the same page #17845

@sentience

Description

@sentience

What version of Tailwind CSS are you using?

v4.1.5 (app) + v3.4.17 (shared UI library)

What build tool (or framework if it abstracts the build tool) are you using?

n/a

What version of Node.js are you using?

v22.14.0

What browser are you using?

Chrome

What operating system are you using?

macOS

Reproduction URL

https://github.com/sentience/tw4-gradient-property-issue

Image

Describe your issue

Tailwind 4 gradient styles present in a page break Tailwind 3 gradient styles present in the same page (such as styles from a component library that has not yet upgraded to Tailwind 4), even when the TW3 styles have their own prefix and are loaded into the components layer.

Tailwind 4 changed the format of background gradient variables such as --tw-gradient-from. In Tailwind 3, these variables contained both a color and a percentage (e.g. #6b7280 var(--tw-gradient-from-position)), whereas in Tailwind 4, the variable with the same name now only contains a color value (e.g. #6b7280). Tailwind 4 also generates @property declarations that restrict these variables so that they are only allowed to contain a color value.

As a result, when a TW3-generated gradient is present in the same page as a TW4-generated gradient, the TW3-generated value for --tw-gradient-from will be discarded by the browser, because the TW4-generated @property declaration says that it's invalid.

A fix for this could be to change the name of the variable in TW4 output (e.g. to --tw-gradient-from-color), so that the @property declarations from TW4 do not interfere with TW3 properties.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions