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

Rule for dark:via-<color> incorrectly overrides base --tw-gradient-to value #10816

Closed
lachieh opened this issue Mar 17, 2023 · 2 comments
Closed

Comments

@lachieh
Copy link

lachieh commented Mar 17, 2023

What version of Tailwind CSS are you using?

For example: v3.2.7

Reproduction URL
https://play.tailwindcss.com/HkVZEWjuc1?layout=horizontal

Describe your issue
Referring to the reproduction, when a base color is set for the from, via and to gradient stops and then changing only the via value in dark mode, the to property gets reset back to the transparent version of the via color.

This is the current output CSS:

.dark .dark\:via-red-500 {
  --tw-gradient-to: rgb(239 68 68 / 0);
  --tw-gradient-stops: var(--tw-gradient-from), #ef4444, var(--tw-gradient-to);
}

However, I would expect the following output:

.dark .dark\:via-red-500 {
  --tw-gradient-stops: var(--tw-gradient-from), #ef4444, var(--tw-gradient-to);
}

Happy to contribute if I could get some guidance on where to look.

@lachieh
Copy link
Author

lachieh commented Mar 17, 2023

On further investigation it looks like it is this PR that changed the behavior to fix a safari bug. Using version 2.0~3.0 has the expected behavior for my use case (override only via-<color> in dark mode)

@adamwathan
Copy link
Member

Hey! Yeah so this is by design at the moment — if we didn't do this then there would be no way to change the via-* color with a variant like dark: and fade to transparent in a way that works in Safari < 15.4.

This same thing happens when you change the from-* color as well:

https://play.tailwindcss.com/SacMYhzGne?layout=horizontal

...and in a bunch of other similar places in Tailwind, for example text-lg leading-5 dark:text-xl would lose the custom line-height when dark mode is enabled.

Solution in all of these cases is just to re-specify the thing that is being overridden color, so dark:to-blue-500 in this case — sort of annoying I get it but better to have to do that and still make fading to transparent possible than not have to re-specify and have no way to fade to transparent.

<div class="bg-gradient-to-r from-blue-500 via-blue-300 to-blue-500 dark:via-blue-900 dark:to-blue-500">&nbsp;</div>

I'll make a note to consider changing this for v4 though, as we're plan to drop support for Safari < 15.4 for v4 already 👍

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