You can use the backdrop-filter USS property to apply filter effects to the area behind a visual element. Unlike the filter property, which processes the element and its children, backdrop-filter processes what’s rendered behind the element. This is useful for effects such as frosted-glass panels, where the content behind a panel appears blurred. The backdrop-filter property is similar to the CSS backdrop-filter property.
When an element has a backdrop filter, UI Toolkit captures the content already rendered behind the element, applies the filter functions to it, and draws the result under the element. The result is clipped to the element’s shape, including its rounded corners. The captured content includes other visual elements rendered behind the element and, for runtime panels that render as a screen overlay, the camera output behind the UI.
The element’s own background, border, and content render on top of the filtered backdrop and aren’t affected by the filter. To keep the filtered backdrop visible, use a transparent or semi-transparent background color for the element.
The backdrop-filter property supports the same built-in filter functions as the filter property:
backdrop-filter: blur(<length>) | grayscale(<number>) | invert(<number>) | opacity(<number>) | sepia(<number>) | tint(<color>) | hue-rotate(<angle>) | contrast(<number>) | drop-shadow(<offset-x> <offset-y> <blur-radius> <color>)
You can combine multiple filter functions in a single backdrop-filter declaration. Filters work as a sequential pipeline where each pass processes the output from the previous pass.
Note: Custom filters aren’t supported with backdrop-filter. If you include a custom filter function, UI Toolkit ignores it and logs a warning.
You can apply backdrop filters to visual elements in UI Builder, USS, or C# code.
To apply a backdrop filter to a visual element in UI Builder:
blur, grayscale, or invert.To apply a backdrop filter to a visual element, use the backdrop-filter property in a USS file. The following example creates a frosted-glass panel that blurs the content behind it:
.frosted-panel {
backdrop-filter: blur(10px);
background-color: rgba(255, 255, 255, 0.2);
border-radius: 15px;
}
To combine multiple filter functions, list them in the same declaration:
.frosted-panel-desaturated {
backdrop-filter: blur(10px) grayscale(50%);
}
If multiple classes each define a backdrop-filter and you apply them to the same element, the filter applied last takes precedence over the earlier ones instead of combining the effects. For more information, refer to Selector precedence.
To apply backdrop filters to a visual element in C# code, create a list of FilterFunction objects and assign it to the visual element’s style.backdropFilter property. For example:
// Create a blur filter using the built-in blur filter function.
var blur = new FilterFunction(FilterFunctionType.Blur);
blur.AddParameter(new FilterParameter(10.0f));
// Apply the blur to the area behind the element.
element.style.backdropFilter = new List<FilterFunction> { blur };
The backdrop-filter property has the following limitations:
backdrop-filter declaration and logs a warning.backdrop-filter.