Skip to content

Tailwind CSS - Backdrop Invert

The backdrop-invert utility applies a CSS backdrop filter that inverts the colors of the area behind an element. This is useful for creating interesting visual effects on semi-transparent elements.

Tailwind provides two primary classes for backdrop inversion.

ClassCSS Properties
backdrop-invert-0—tw-backdrop-invert: invert(0);
backdrop-invert—tw-backdrop-invert: invert(1);

Backdrop filters are most effective when combined. Here, we’ll use backdrop-invert along with backdrop-blur and backdrop-opacity to create a modern “glassmorphism” card effect. The text on the card inverts the color of the image behind it.

Note: For backdrop filters to be visible, the element’s background must be semi-transparent.

<div class="relative w-full h-80 flex items-center justify-center">
<!-- Background Image -->
<img src="/path/to/your/vibrant-image.jpg" alt="Abstract background" class="absolute inset-0 w-full h-full object-cover" />
<!-- Glassmorphism Card -->
<div class="relative w-72 h-40 rounded-xl bg-white/20 backdrop-blur-lg backdrop-invert shadow-lg flex items-center justify-center">
<p class="text-2xl font-bold text-gray-800">Inverted</p>
</div>
</div>

You can apply backdrop filters conditionally, such as on hover. This can create engaging micro-interactions.

<div class="relative w-48 h-48">
<img src="/path/to/image.jpg" class="w-full h-full object-cover" />
<div class="absolute inset-0 bg-black/10 transition-all duration-300
hover:backdrop-invert">
</div>
</div>

Backdrop filters are now widely supported in modern browsers, but it’s always good practice to check caniuse.com for the latest compatibility data. Be aware that complex filters, especially backdrop-blur, can be performance-intensive and should be used thoughtfully.