Shirasagi0012.MaterialColorUtilities.Avalonia 0.2.0

dotnet add package Shirasagi0012.MaterialColorUtilities.Avalonia --version 0.2.0
                    
NuGet\Install-Package Shirasagi0012.MaterialColorUtilities.Avalonia -Version 0.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Shirasagi0012.MaterialColorUtilities.Avalonia" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Shirasagi0012.MaterialColorUtilities.Avalonia" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="Shirasagi0012.MaterialColorUtilities.Avalonia" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Shirasagi0012.MaterialColorUtilities.Avalonia --version 0.2.0
                    
#r "nuget: Shirasagi0012.MaterialColorUtilities.Avalonia, 0.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Shirasagi0012.MaterialColorUtilities.Avalonia@0.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Shirasagi0012.MaterialColorUtilities.Avalonia&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Shirasagi0012.MaterialColorUtilities.Avalonia&version=0.2.0
                    
Install as a Cake Tool

Material Color Utilities

Color is a powerful design tool and part of the Material system along with styles like typography and shape. In products, colors and the way they are used can be vast and varied. An app’s color scheme can express brand and style. Semantic colors can communicate meaning. And color contrast control supports visual accessibility.

In many design systems of the past, designers manually picked app colors to support the necessary range of color applications and use cases. Material 3 introduces a dynamic color system, which does not rely on hand-picked colors. Instead, it uses color algorithms to generate beautiful, accessible color schemes based on dynamic inputs like a user’s wallpaper. This enables greater flexibility, personalization, and expression, all while streamlining work for designers and teams.

Material Color Ultilities (MCU) powers dynamic color with a set of color libraries containing algorithms and utilities that make it easier for you to develop color themes and schemes in your app.

<video autoplay muted loop src="https://user-images.githubusercontent.com/6655696/146014425-8e8e04bc-e646-4cc2-a3e7-97497a3e1b09.mp4" data-canonical-src="https://user-images.githubusercontent.com/6655696/146014425-8e8e04bc-e646-4cc2-a3e7-97497a3e1b09.mp4" class="d-block rounded-bottom-2 width-fit" style="max-width:640px;"></video>

MaterialColorUtilities for .NET

This repository contains a C# port of Google's official material-color-utilities library.

Motivation

An earlier C# port (albi005/MaterialColorUtilities) exists but seems no longer actively maintained and outdated. This project was initiated to provide an up-to-date implementation targeting the latest .NET platform.

Current Status

This implementation is currently a work-in-progress. The API is mostly the same as the original, with minor adjustments to add some C# flavor.

Most parts of material-color-utilities (except CorePalette, which is labeled as deprecated) and all unit tests have been ported. All ported unit tests are passing. Feel free to try it out and give your feedback.

This project support all color schemes from original Material Design 3 and Material 3 Expressive. Watch variant is also ported.

⚠️ This library is not yet ready for production use.

APIs

Core libs

Most API are identical to original implementation. There are some differences:

  • For convenience, this library uses ArgbColor struct to represent a color, instead of an int as the original implementation does.

Avalonia integration

Setup

There are a separate project for Avalonia app to use, which give you ability to directly define a dynamic scheme in XAML with no C# code needed, and easy access to material color tokens with markup extensions. Seed color can be bind to a property, or a dynamic resource. The binding layer is powered by DesignTokens.Avalonia.

To setup a dynamic scheme, just set an attached property MaterialColor.Scheme with your preferred scheme. Set to Application will apply to the whole app. The scheme will inherit to all element down the logical tree.

<Application>
    <mcu:MaterialColor.Scheme>
        <mcu:TonalSpotScheme Color="{DynamicResource SystemAccentColor}" />
    </mcu:MaterialColor.Scheme>
</Application>

Thanks to Avalonia's ability to use any type for markup extensions, the XAML can be much simplified:

<Border mcu:MaterialColor.Scheme="{mcu:TonalSpotScheme {Binding ThemeColor}}" />
Color Extraction

Currently color extract XAML markup extension is not implemented, but it will be here after some time.

Color Token with Markup Extension

Access Material 3 design tokens using strongly-typed markup extensions. These extensions automatically resolve to either a SolidColorBrush or a Color binding depending on the target property. The binding will automatically update when theme/scheme/seed color change.

  • MdSysColor (SysColorToken token)
  • MdRefPalette (RefPaletteToken palette, byte tone)
<Border Background="{mcu:MdRefPalette Primary, 60}" Grid.Row="0">
    <TextBlock Classes="label-medium" Foreground="{mcu:MdSysColor OnPrimary}">Primary</TextBlock>
</Border>
Custom & Extended Colors

Currently custom color token and extended color token are not implemented, but it will be here after some time.

Theme Override

By default, the MdSysColor markup extension reacts to the current ActualThemeVariant. However, you can explicitly set the Theme parameter to ensure a resource always resolves to a specific theme, which is particularly useful when defining ThemeDictionaries.

<ResourceDictionary>
    <ResourceDictionary.ThemeDictionaries>
        <ResourceDictionary x:Key="Light">
            <SolidColorBrush x:Key="SystemControlBackgroundBrush" 
                             Color="{mcu:MdSysColor Surface, Theme=Light}" />
        </ResourceDictionary>

        <ResourceDictionary x:Key="Dark">
            <SolidColorBrush x:Key="SystemControlBackgroundBrush" 
                             Color="{mcu:MdSysColor Surface, Theme=Dark}" />
        </ResourceDictionary>
    </ResourceDictionary.ThemeDictionaries>
</ResourceDictionary>
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.0 151 3/17/2026
0.1.0 117 3/4/2026
0.0.2 127 2/24/2026