MaterialTheming 2.0.0

dotnet add package MaterialTheming --version 2.0.0
                    
NuGet\Install-Package MaterialTheming -Version 2.0.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="MaterialTheming" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MaterialTheming" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="MaterialTheming" />
                    
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 MaterialTheming --version 2.0.0
                    
#r "nuget: MaterialTheming, 2.0.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 MaterialTheming@2.0.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=MaterialTheming&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=MaterialTheming&version=2.0.0
                    
Install as a Cake Tool

MaterialTheming

NuGet GitHub Actions Workflow Status

MaterialTheming is a .NET library that implements the Google Material 3 (Material You) color system. It allows developers to generate color schemes and dynamic themes.

It is independent of the frontend platform you are building your app on. Whether you are building with Blazor, Maui, WPF, WinForms or Avalonia, this library provides the tools to calculate color schemes to style your app with.

This library is a faithful recreation of the official Java implementation of the Material 3 color system. It provides an additional Fluent API to build your custom theme.

Features

  • Material 3 Compliance: Full implementation of the Material Design 3 color algorithms. Including the proprietary HCT color space.
  • Verified Accuracy: Output results tested against the official Google Java implementation.
  • Dynamic Color: Generate complete schemes from a single source color.
  • High Accessibility: Uses color math and color theory to ensure accessible contrast ratios and accurate tonal shifts.
  • Fluent API Builder: An intuitive, readable syntax for constructing and customizing themes.

Installation

The library is distributed as a NuGet package.

Add it to your project via the dotnet CLI:

dotnet add package MaterialTheming

Or search for MaterialTheming in the Visual Studio NuGet Package Manager.

Getting Started

The core of the library is generating a ThemeColors object based on a source color input. This object has accessible properties for the color roles defined in Material 3. You can do this via the Fluent API ThemeBuilder.

// Generate the colors from a single source color
var themeColors = ThemeBuilder
    .CreateFromSourceColor("#6750A4")
    .Build();

// Access the generated colors
var surface = themeColors.Surface;
var onSurface = themeColors.OnSurface;
var primary = themeColors.Primary;
var onPrimary = themeColors.OnPrimary;

Fluent API Theme Builder

The library features a Fluent API ThemeBuilder that makes creating themes simple and readable. This is the recommended way to use the library.

You can customize the generation process by chaining methods to define the various parameters to make the built theme fit your requirements.

1. Basic Theme from Source Color

Generate a standard theme based on a single source color.

var myThemeColors = ThemeBuilder
    .CreateFromSourceColor("#006495") // Your source color
    .Build();

2. Customizing the Scheme

You can control various aspects of the generated theme. These include all the options that the official Material 3 color implementation provides:

  • Source color
  • Dark or light mode
  • Contrast level
  • Variant
  • Platform
  • Spec version
var customThemeColors = ThemeBuilder
    .CreateFromSourceColor("#D32F2F")
    .WithMode(ThemeMode.Dark)               // Use a dark mode
    .WithContrastLevel(ContrastLevel.High)  // Use a high contrast of foregound to background roles
    .WithVariant(Variant.Expressive)        // Use the 'Expressive' variant to generate the palettes
    .WithPlatform(Platform.Phone)           // Use phone as platform (also suited for desktop)
    .WithSpecVersion(SpecVersion.Spec2025)  // Use the Spec Version released in 2025
    .Build();

3. Building from Material Theme Builder JSON

If you already created a material theme at the official Material Theme Builder you can export it as a JSON file there. This JSON file can also be used in the ThemeBuilder to extract the contained ThemeColors.

var themeBuilderJsonThemeColors = ThemeBuilder
    .CreateFromJsonContent(myJsonContent)    // Provide a string that contains the exported JSON content
    .WithMode(ThemeMode.Dark)                // Build the contained dark theme
    .WithContrastLevel(ContrastLevel.Normal) // Build the contained normal contrast level
    .Build();

Correctness & Compliance

GitHub Actions Workflow Status

This library is not just an approximation of Material Design. It is a full re-implementation tested against the source of truth. The official Material 3 Java implementation by Google.

The output results are verified to be fully compliant with said implementation. The test suite covers an exhaustive matrix of theme creation parameters:

  • Source Colors: A selection of 8 source colors with different hues.
  • Theme Modes: Light and Dark.
  • Contrast Levels: Normal, Medium, and High contrast level.
  • Variants: All 9 variants defined in the Material 3 color system.
  • Spec Versions: Both specification versions. 2021 and 2025.

All test expectations were programmatically generated directly from the official Java library results, ensuring that the colors you generate in .NET are identical to those generated by the official Java implementation.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
.NET Framework net48 is compatible.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
2.0.0 62 2/20/2026
1.2.4 178 2/16/2026
1.2.3 107 2/9/2026
1.2.2 130 2/1/2026
1.1.1 72 1/27/2026
1.1.0 47 1/27/2026
1.0.1 86 1/21/2026
1.0.0 45 1/20/2026
0.2.0 63 1/2/2026
0.1.2 63 1/1/2026