# MaterialColorUtilities.Maui *A library for adding Material You colors to your .NET MAUI app* ## Features - Dynamic theming on every platform (except iOS) - Light/dark theme support - Automatically storing and reapplying seed color/dark mode/style preferences All of these can be turned on/off at any time. ## Getting started 1. Add a reference to the package. For instructions visit the [NuGet page](https://www.nuget.org/packages/MaterialColorUtilities.Maui). 2. Call the `UseMaterialColors` extension method in `MauiProgram.cs`. This will add all the services required for theming to the service container. ```diff +using MaterialColorUtilities.Maui; namespace YourApp; public static class MauiProgram { public static MauiApp CreateMauiApp() { MauiAppBuilder builder = MauiApp .CreateBuilder() + .UseMaterialColors() .UseMauiApp(); return builder.Build(); } } ``` You can specify the fallback seed as an argument to the extension method or use a lambda for more options: ```csharp .UseMaterialColors(options => { options.FallbackSeed = 0xB000B5; options.UseDynamicColor = false; }) ``` 3. Initialize MaterialColorService with a ResourceDictionary:
If you use XAML click here Copy these lines: ```xml ``` and update `App.xaml` like this: ```diff + + + + ```
If you don't use XAML click here Edit `App.xaml.cs` like this: ```diff +using MaterialColorUtilities.Maui; public class App : Application { public App() { + IMaterialColorService.Current.Initialize(this.Resources); MainPage = new AppShell(); } } ```
### Usage By default the colors are added as global resources. You can access them - in XAML using DynamicResource: ```xml