tailwindcss icon indicating copy to clipboard operation
tailwindcss copied to clipboard

`backdrop-blur-` does not work on webkit browsers (ie safari)

Open tedbrine opened this issue 2 years ago • 21 comments

What version of Tailwind CSS are you using? v3.4.4

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

Next v14.2.2 PostCSS v8

What version of Node.js are you using?

Node v20.11.1 Bun v1.1.8

What browser are you using?

Safari [macOS/iOS] (does NOT work as expected) v17.5 Brave [Windows] (works as expected) v1.67.116 Arc [macOS] (works as expected) v1.47.1 Edge [Windows] (works as expected) v126.0.2592.56

What operating system are you using?

macOS 14.5 Windows 11 23H2

Reproduction URL

https://play.tailwindcss.com/s0uKhW1RIh

Describe your issue

The backdrop-blur- classes do not add the -webkit- style, so Safari and other webkit browsers aren't being styled with a backdrop blur.

In this mean while, ot solve this I manually added each of the classes to my global css file

.backdrop-blur-3xl {
  --tw-backdrop-blur: blur(64px);
  -webkit-backdrop-filter: var(--tw-backdrop-blur);
  backdrop-filter: var(--tw-backdrop-blur);
}
...etc

tedbrine avatar Jun 16 '24 10:06 tedbrine

Hey! In your own projects this is handled by autoprefixer which uses your browserslist configuration to determine supported browsers and what prefixes need to be applied. As for Tailwind Play, there was a configuration issue (also related to autoprefixer) that caused this but I've fixed it and your Play now works and shows the blur correctly!

Thanks for letting us know 👍

thecrypticace avatar Jun 17 '24 18:06 thecrypticace

As for Tailwind Play, there was a configuration issue (also related to autoprefixer) that caused this but I've fixed it and your Play now works and shows the blur correctly!

@thecrypticace what was that configuration issue?

I can still see this issue on webkit even after using autoprefixer and browserslist. Also there is a strange thing, when I manually put the css variable value from inspector(copy) to inspector(paste), then it works:

https://github.com/user-attachments/assets/3cb54c14-843a-49d8-9a00-85d9961a502b

Muhammed-Rahif avatar Oct 30 '24 10:10 Muhammed-Rahif

@Muhammed-Rahif What browser is that? It's working here.

thecrypticace avatar Oct 30 '24 10:10 thecrypticace

It's a tauri instance: https://tauri.app/start/

Muhammed-Rahif avatar Oct 30 '24 10:10 Muhammed-Rahif

FYI: Tauri uses WRY (WebKitGTK for Linux, WebKit for MacOS, Webview2 for Windows). And I am using tauri on linux. Source: https://github.com/Elanis/web-to-desktop-framework-comparison#major-characteristics

Muhammed-Rahif avatar Oct 30 '24 10:10 Muhammed-Rahif

I wonder if it's a much older webkit version where variable fallbacks worked a bit differently. 🤔

thecrypticace avatar Oct 30 '24 10:10 thecrypticace

I'll see if I can spin up a linux box and give it a test (may not happen today but hopefully this week)

thecrypticace avatar Oct 30 '24 10:10 thecrypticace

any update?

Heraclito-Q-Saldanha avatar Nov 28 '24 06:11 Heraclito-Q-Saldanha

Why is this issue closed? I can reproduce

Heraclito-Q-Saldanha avatar Nov 28 '24 11:11 Heraclito-Q-Saldanha

I have the exact same issue on Orion Browser version 0.99.130.2 on macOS which uses WebKit 621.1.2.111.4. I can reproduce the steps in the video by putting the value manually in the web inspector.

I do not however have the issue a on the iOS version of Orion Browser version 1.3.15 which uses WebKit 8619.2.8.10.7. I checked on macOS Safari (version 18.2) which uses a slightly older WebKit (620.1.16) and do not have the issue either.

lufiia avatar Jan 07 '25 22:01 lufiia

Using Safari Desktop Version 18.2 (19620.1.16.111.6, 19620):

Very odd: var does not work with -webkit-backdrop-filter. Even though Safari tells me that the variable has a value, it doesn't apply any blur effect on the element:

Image

Using var inside blur also does not work:

Image

I can test and find that the variable works for border-width but not for -webkit-backdrop-filter:

Image

This is the only way to get the blur working in Safari:

If I directly apply the actual value, then the blur effect works and is applied on the element.

Image

This would mean the Tailwind generated CSS here does not work in Safari:

.backdrop-blur-sm {
  --tw-backdrop-blur: blur(var(--blur-sm));
  -webkit-backdrop-filter: var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);
  backdrop-filter: var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);
}

We have to override it and insert all the actual values for Safari:

  -webkit-backdrop-filter: blur(8px) brightness( ... etc. ) etc.;

Please re-open or tell us if we should open a new issue.

ADTC avatar Feb 13 '25 09:02 ADTC

Looks like it works to me (with and without the @property): https://play.tailwindcss.com/xuWb6hIqXV?file=css

Image

thecrypticace avatar Feb 13 '25 13:02 thecrypticace

@thecrypticace I can't ascertain if you're testing on Safari, and which version.

ADTC avatar Feb 13 '25 16:02 ADTC

Safari 18.3 — this worked in 18.2 and before as well. This is why I also gave a link to to the Play.

thecrypticace avatar Feb 13 '25 16:02 thecrypticace

I updated to Safari Desktop Version 18.3 (19620.2.4.111.8, 19620) but still:

Variable does not work:

Image

This version also does not work, even if it does the fallback:

--my-var2: 20px; /* disable to do the fallback */
-webkit-backdrop-filter: blur(var(--my-var2, 5px));

Only inline fixed value works:

Image

Conclusion

It looks like Safari doesn't support CSS variables in -webkit-backdrop-filter for some odd reason.

ADTC avatar Feb 13 '25 17:02 ADTC

What OS are you running? and hardware? (Also are you running this in a VM?)

It absolutely does support CSS variables so the fact that it's not working for you is a definite bug in WebKit.

thecrypticace avatar Feb 13 '25 17:02 thecrypticace

@thecrypticace Apple M1 Pro, macOS Sonoma 14.7.2 (23H311), MacBook Pro.

There's no VM.

Edit: Please don't tell me this will only work in Sequoia. I'm not upgrading yet because I want to stay in a stable version of macOS. Besides, Safari itself is separate from macOS.

ADTC avatar Feb 13 '25 17:02 ADTC

This looks like an eerily similar problem but for a different property: http://aaronpinero.net/learned/posts/2024/04/2024-04-17/

ADTC avatar Feb 13 '25 17:02 ADTC

Any thoughts on this?

ADTC avatar Feb 16 '25 15:02 ADTC