New in Chrome 76: the frosted glass effect with backdrop-filter
Tags: chrome, css
Published: 2019-07-31 18:50:35

---
title: New in Chrome 76: the frosted glass effect with backdrop-filter
published: true
tags: chrome, css 
canonical_url: https://blog.logrocket.com/new-in-chrome-76/
---

![](https://thepracticaldev.s3.amazonaws.com/i/913i11wqd2uc4tlobzj9.png)

Have you ever wanted to recreate that typical frosted glass effect/background blur from iOS devices on the web? The [newest release of Google Chrome](https://developers.google.com/web/updates/2019/07/nic76) makes it possible with just a couple lines of CSS, thanks to the implementation of the backdrop-filter property!

## Understanding the backdrop-filter property

As the self-descriptive name tells us, backdrop-filter allows us to apply a CSS filter to the element’s backdrop. But how do we define the backdrop?

In CSS “backdrop” stands for [whatever is painted _behind_ the element](https://drafts.fxtf.org/filter-effects-2/#backdrop-root-image). This means, of course, that the first thing we should do to use a `backdrop-filter` is add some kind of transparency to allow us to see through it.

For this purpose, we might either apply no background to the element, set it as a semi-transparent one via RGBA, or apply an opacity to the whole element. Remember that the latter will also affect the element’s text node and all the descendants, so this is probably not the right choice for most scenarios. Let’s start with a semi-transparent white background:

[![LogRocket Free Trial Banner](https://i0.wp.com/blog.logrocket.com/wp-content/uploads/2017/03/f760c-1gpjapknnuyhu8esa3z0jga.png?resize=1200%2C280&ssl=1)](https://logrocket.com/signup/)

```jsx
.frosted{
      background: rgba(255, 255, 255, 0.3);
    }
```

Next, we will want to declare the filter itself. Backdrop-filter accepts exactly the same values as the [filter](https://developer.mozilla.org/en-US/docs/Web/CSS/filter) property, so we can affect the backdrop in many ways. From the simple blur to grayscale or sepia, or even any fancy Instagram-like filters shifting the image hue, brightness, saturation, and contrast.

Let’s apply the blur for our frosted-glass effect:

```jsx
.frosted{
  background: rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(8px);
}
```

And that’s pretty much it. I said “a couple lines” and I meant it. With some positioning magic, we can get results as follows:
{% codepen https://codepen.io/facundocorradini/pen/OKpreN %}
![](https://i0.wp.com/blog.logrocket.com/wp-content/uploads/2019/07/frosted-glass-overlay.png?resize=737%2C482&ssl=1)<figcaption id="caption-attachment-4340">The result without backdrop-filter (left) and with it (right)</figcaption>

## Making it safe for other browsers

At first, only [Safari and Edge](https://caniuse.com/#search=backdrop-filter) supported this property, with Chrome and Chromium-based browsers joining now. But we still should make our code safe for Firefox and other minor browsers and devices.

The good news is that, as with anything in CSS, if a browser finds a declaration that it doesn’t understand it will simply ignore it. So the approach we used above is safe-ish, as any browser that lacks support for backdrop-filter will provide a semi-transparent white background with no effect instead.

But there are situations where that won’t be enough. Perhaps the semi-transparent background without a blurred backdrop fails to provide enough contrast for the text, or we want to provide a completely different style to the element for browsers that don’t support backdrop-filter.

The safer way to do this is by using the @supports query and progressive enhancement. We should start by declaring the styles for browsers that don’t support it.

In this case, I’ll be using an almost-opaque white background to increase readability when no blur is applied.

```jsx
.frosted{
  background: rgba(255, 255, 255, 0.9);
}
```

Then using the @supports query, we can apply the effect on any browser that supports it, plus dial down the alpha channel to increase transparency.

```jsx
/* sets default styling */
.frosted{
  background: rgba(255, 255, 255, 0.9);
}

/* applies semi-transparent background for browsers that support backdrop-filter */
@supports (backdrop-filter: none) {
  .frosted {
      background: rgba(255, 255, 255, 0.3);
      backdrop-filter: blur(8px);
  }
}
```

Notice I’m using “backdrop-filter: none” as the condition. It’s generally considered a good practice to use the simplest value of a property when checking for browser support. I could have used something like “@supports (backdrop-filter: blur(8px))”, but that would be repetitive and can look extremely confusing if someone changes the filter in the future.

## Much more than just a frosted glass

I focused on the frosted glass as that’s one that I’ve been wanting to use for eons, but we can apply any filter we’d like to, including:

- blur
- brightness
- contrast
- grayscale
- hue-rotate
- invert
- opacity
- saturate
- sepia

Furthermore, we can even combine them to form advanced ones. To do so, we just have to define all filters in the property (bear in mind that the values must **not**  be comma-separated… quite an inconsistency between different CSS properties there).

For instance, to recreate the Walden effect, we could use:

```jsx
.walden{
  backdrop-filter:
    contrast(100%)
    brightness(110%)
    saturate(160%)
    sepia(30%)
    hue-rotate(350deg)
  ;
}
```

(values from [Una Kravets](https://twitter.com/una)’ [CSSgram](https://una.im/CSSgram/))
{% codepen https://codepen.io/facundocorradini/pen/RXpOqX %}
![walden effect picture of puppy](https://i1.wp.com/blog.logrocket.com/wp-content/uploads/2019/07/waldeneffect.png?resize=730%2C362&ssl=1)<figcaption id="caption-attachment-4343">The result in a browser that doesn’t support backdrop-filter (left) vs one that does (right)</figcaption>

## Much more in Chrome 76!

Of course, backdrop-filter is just one of the many improvements on this new release. Other great news includes the support for [prefers-color-scheme media query](https://blog.logrocket.com/whats-new-in-firefox-67-prefers-color-scheme-and-more-195be81df03f/), a new button in the omnibar to simplify installation of PWAs, updates to numerous APKs, and more. You can read about them at [Chrome’s blog](https://developers.google.com/web/updates/2019/07/nic76).
* * *
## Plug: [LogRocket](https://logrocket.com/signup/), a DVR for web apps
 
![LogRocket Dashboard Free Trial Banner](https://i2.wp.com/blog.logrocket.com/wp-content/uploads/2017/03/1d0cd-1s_rmyo6nbrasp-xtvbaxfg.png?resize=1200%2C677&ssl=1)
 
[LogRocket](https://logrocket.com/signup/) is a frontend logging tool that lets you replay problems as if they happened in your own browser. Instead of guessing why errors happen, or asking users for screenshots and log dumps, LogRocket lets you replay the session to quickly understand what went wrong. It works perfectly with any app, regardless of framework, and has plugins to log additional context from Redux, Vuex, and @ngrx/store.
 
In addition to logging Redux actions and state, LogRocket records console logs, JavaScript errors, stacktraces, network requests/responses with headers + bodies, browser metadata, and custom logs. It also instruments the DOM to record the HTML and CSS on the page, recreating pixel-perfect videos of even the most complex single-page apps.
 
[Try it for free](https://logrocket.com/signup/).
* * *
The post [New in Chrome 76: the frosted glass effect with backdrop-filter](https://blog.logrocket.com/new-in-chrome-76/) appeared first on [LogRocket Blog](https://blog.logrocket.com).