Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v4] Gradient percentage range not working anymore (e.g. via-[percentage:10%_90%]) #16683

Open
ramrami opened this issue Feb 20, 2025 · 3 comments

Comments

@ramrami
Copy link

ramrami commented Feb 20, 2025

What version of Tailwind CSS are you using?
v4.0.7

What build tool (or framework if it abstracts the build tool) are you using?
gulp v5.0.0 + Postcss

What version of Node.js are you using?
v20.18.1

What browser are you using?
Brave + Safari

What operating system are you using?
macOS

Reproduction URL
https://play.tailwindcss.com/16SCposb3z

Describe your issue

Using the following class doesn't give the desired result in v4:
bg-gradient-to-r from-sky-500 to-sky-500 via-rose-500 via-[percentage:10%_90%]

v3

Image

v4

Image

The browser considers the property as invalid because it's not a <length-percentage>:

Image

@philipp-spiess
Copy link
Member

That's definitely a "pick your poison" kind of situation. If we change the type of the --tw-gradient-via-position variable, you won't be able to animate it anymore but otherwise you can only add one percentage value here. 🤔

A temporary solution for you might be to use arbitrary values instead: https://play.tailwindcss.com/J11BlY9xhK

bg-[linear-gradient(to_right,var(--color-sky-500)_0%,var(--color-rose-500)_10%,var(--color-rose-500)_90%,_var(--color-sky-500)_100%)]

@ramrami
Copy link
Author

ramrami commented Feb 21, 2025

Yeah, that makes sense.

If I may suggest, maybe we could split this variable in two? since every color stop has one or two positions, we could use --tw-gradient-via-start-position and --tw-gradient-via-end-position

@ramrami
Copy link
Author

ramrami commented Feb 21, 2025

Nevermind my previous suggestion, just remembered that @Property vars need a default value, so it probably won't work because you can't leave the values blank like in v3 🤔

Edit: see #15910

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants