|
| 1 | +--- |
| 2 | +title: In-app acrylic |
| 3 | +description: Learn how to use AcrylicBrush to apply in-app acrylic effects to UI elements in your WinUI app. |
| 4 | +ms.topic: how-to |
| 5 | +ms.date: 02/27/2026 |
| 6 | +keywords: windows, windows app development, Windows App SDK, Acrylic, AcrylicBrush, materials |
| 7 | +ms.localizationpriority: medium |
| 8 | +--- |
| 9 | + |
| 10 | +# In-app acrylic |
| 11 | + |
| 12 | +You can apply in-app acrylic to your app's surfaces using a XAML [AcrylicBrush](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.media.acrylicbrush) or predefined `AcrylicBrush` theme resources. |
| 13 | + |
| 14 | +> [!div class="nextstepaction"] |
| 15 | +> [Open the WinUI Gallery app and see Acrylic in action](winui3gallery://item/Acrylic) |
| 16 | +
|
| 17 | +WinUI includes a collection of brush theme resources that respect the app's theme and fall back to solid colors as needed. To paint a specific surface, apply one of the theme resources to element backgrounds just as you would apply any other brush resource. |
| 18 | + |
| 19 | +```xaml |
| 20 | +<Grid Background="{ThemeResource AcrylicInAppFillColorDefaultBrush}"> |
| 21 | +``` |
| 22 | + |
| 23 | +> [!NOTE] |
| 24 | +> You can view these resources in the [AcrylicBrush theme resources file, in the microsoft-ui-xaml GitHub repo](https://github.com/microsoft/microsoft-ui-xaml/blob/6aed8d97fdecfe9b19d70c36bd1dacd9c6add7c1/dev/Materials/Acrylic/AcrylicBrush_19h1_themeresources.xaml#L11). |
| 25 | +
|
| 26 | +## Custom acrylic brush |
| 27 | + |
| 28 | +You may choose to add a color tint to your app's acrylic to show branding or provide visual balance with other elements on the page. To show color rather than grayscale, you need to define your own acrylic brushes using the following properties. |
| 29 | + |
| 30 | +- **TintColor**: the color/tint overlay layer. |
| 31 | +- **TintOpacity**: the opacity of the tint layer. |
| 32 | +- **TintLuminosityOpacity**: controls the amount of saturation that is allowed through the acrylic surface from the background. |
| 33 | +- **FallbackColor**: the solid color that replaces acrylic in Battery Saver. For background acrylic, fallback color also replaces acrylic when your app isn't in the active desktop window. |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | +To add an acrylic brush, define the three resources for dark, light, and high contrast themes. In high contrast, we recommend that you use a [SolidColorBrush](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.media.solidcolorbrush) with the same `x:Key` as the dark/light AcrylicBrush. |
| 42 | + |
| 43 | +> [!NOTE] |
| 44 | +> If you don't specify a `TintLuminosityOpacity` value, the system will automatically adjust its value based on your TintColor and TintOpacity. |
| 45 | +
|
| 46 | +```xaml |
| 47 | +<ResourceDictionary.ThemeDictionaries> |
| 48 | + <ResourceDictionary x:Key="Default"> |
| 49 | + <AcrylicBrush x:Key="MyAcrylicBrush" |
| 50 | + TintColor="#FFFF0000" |
| 51 | + TintOpacity="0.8" |
| 52 | + TintLuminosityOpacity="0.5" |
| 53 | + FallbackColor="#FF7F0000"/> |
| 54 | + </ResourceDictionary> |
| 55 | + |
| 56 | + <ResourceDictionary x:Key="HighContrast"> |
| 57 | + <SolidColorBrush x:Key="MyAcrylicBrush" |
| 58 | + Color="{ThemeResource SystemColorWindowColor}"/> |
| 59 | + </ResourceDictionary> |
| 60 | + |
| 61 | + <ResourceDictionary x:Key="Light"> |
| 62 | + <AcrylicBrush x:Key="MyAcrylicBrush" |
| 63 | + TintColor="#FFFF0000" |
| 64 | + TintOpacity="0.8" |
| 65 | + TintLuminosityOpacity="0.5" |
| 66 | + FallbackColor="#FFFF7F7F"/> |
| 67 | + </ResourceDictionary> |
| 68 | +</ResourceDictionary.ThemeDictionaries> |
| 69 | +``` |
| 70 | + |
| 71 | +The following sample shows how to declare an AcrylicBrush in code. |
| 72 | + |
| 73 | +```csharp |
| 74 | +AcrylicBrush myBrush = new AcrylicBrush(); |
| 75 | +myBrush.TintColor = Color.FromArgb(255, 202, 24, 37); |
| 76 | +myBrush.FallbackColor = Color.FromArgb(255, 202, 24, 37); |
| 77 | +myBrush.TintOpacity = 0.6; |
| 78 | + |
| 79 | +grid.Fill = myBrush; |
| 80 | +``` |
| 81 | + |
| 82 | +## Related articles |
| 83 | + |
| 84 | +- [Materials overview](materials.md) |
| 85 | +- [System backdrops (Mica/Acrylic)](system-backdrops.md) |
| 86 | +- [Acrylic design guidance](../../design/style/acrylic.md) |
0 commit comments