Skip to content

backdrop-filter: grayscale()

Utilities for applying backdrop grayscale filters to an element.

Quick reference

ClassStyles
backdrop-grayscalebackdrop-filter: grayscale(100%);
backdrop-grayscale-<number>backdrop-filter: grayscale(<number>%);
backdrop-grayscale-(<custom-property>)backdrop-filter: grayscale(var(<custom-property>));
backdrop-grayscale-[<value>]backdrop-filter: grayscale(<value>);

Examples

Basic example

Use utilities like backdrop-grayscale and backdrop-grayscale-0 to control the grayscale of an element's backdrop:

html
<div class="bg-[url(/img/mountains.jpg)]">
  <div class="bg-white/30 backdrop-grayscale ..."></div>
</div>
<div class="bg-[url(/img/mountains.jpg)]">
  <div class="bg-white/30 backdrop-grayscale-0 ..."></div>
</div>

Using a custom value

Use the backdrop-grayscale-[&lt;value&gt;] syntax to set the backdrop grayscale based on a completely custom value:

html
<div class="backdrop-grayscale-[.8] ...">
  <!-- ... -->
</div>

For CSS variables, you can also use the backdrop-grayscale-(&lt;custom-property&gt;) syntax:

html
<div class="backdrop-grayscale-(--my-backdrop-grayscale) ...">
  <!-- ... -->
</div>

This is just a shorthand for backdrop-grayscale-[var(&lt;custom-property&gt;)] that adds the var() function for you automatically.

Responsive design

Prefix a backdrop-filter: grayscale() utility with a breakpoint variant like md: to only apply the utility at medium screen sizes and above:

html
<div class="backdrop-grayscale md:backdrop-grayscale-0 ...">
  <!-- ... -->
</div>

Released under the MIT License.