Backdrop Filter
Tailwind CSS version
v2.1+
Utilities for enabling and disabling backdrop filters on an element.
Default class reference
Class | Properties |
---|---|
backdrop-filter | 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-none | backdrop-filter: none; |
Usage
Use the backdrop-filter
utility to enable backdrop filters (in combination with other backdrop filter utilities like backdrop-blur
or backdrop-grayscale
), and the backdrop-filter-none
utility to remove filters.
<div class="backdrop-filter backdrop-grayscale backdrop-blur-md backdrop-contrast-200 ...">
<!-- ... -->
</div>
Responsive
To control backdrop filters at a specific breakpoint, add a {screen}:
prefix to any existing backdrop filter utility. For example, use md:backdrop-filter-none
to apply the backdrop-filter-none
utility at only medium screen sizes and above.
<div class="backdrop-filter backdrop-blur-lg md:backdrop-filter-none ...">
<!-- ... -->
</div>
For more information about Tailwind’s responsive design features, check out the Responsive Design documentation.
Customizing
Variants
By default, only responsive variants are generated for backdrop-filter utilities.
You can control which variants are generated for the backdrop-filter utilities by modifying the backdropFilter
property in the variants
section of your tailwind.config.js
file.
For example, this config will also generate hover and focus variants:
// tailwind.config.js
module.exports = {
variants: {
extend: {
// ...
+ backdropFilter: ['hover', 'focus'],
}
}
}
Disabling
If you don’t plan to use the backdrop-filter utilities in your project, you can disable them entirely by setting the backdropFilter
property to false
in the corePlugins
section of your config file:
// tailwind.config.js
module.exports = {
corePlugins: {
// ...
+ backdropFilter: false,
}
}