Community.Mudblazor.ThemeHelper 1.0.4

dotnet add package Community.Mudblazor.ThemeHelper --version 1.0.4
NuGet\Install-Package Community.Mudblazor.ThemeHelper -Version 1.0.4
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="Community.Mudblazor.ThemeHelper" Version="1.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Community.Mudblazor.ThemeHelper --version 1.0.4
#r "nuget: Community.Mudblazor.ThemeHelper, 1.0.4"
#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.
// Install Community.Mudblazor.ThemeHelper as a Cake Addin
#addin nuget:?package=Community.Mudblazor.ThemeHelper&version=1.0.4

// Install Community.Mudblazor.ThemeHelper as a Cake Tool
#tool nuget:?package=Community.Mudblazor.ThemeHelper&version=1.0.4

Community.MudBlazor.ThemeHelper

A simple library to make sharing a single MudBlazor theme across multiple projects and into Razor Class Libraries that use MudBlazor.

Usage:

using Community.Mudblazor.ThemeHelper;

Create a class in your main project that implements IThemeHelper

*This is where you will define your theme

public class ThemeHelperExample : IThemeHelper
{
  public MudTheme GetTheme()
      {
        return new MudTheme()
          {
              Palette = new Palette()
              {
                  Primary = Colors.Blue.Default,
                  Secondary = Colors.Green.Accent4,
                  AppbarBackground = Colors.Red.Default,
              },
              PaletteDark = new PaletteDark()
              {
                  Primary = Colors.Blue.Lighten1
              },
              LayoutProperties = new LayoutProperties()
              {
                  DrawerWidthLeft = "260px",
                  DrawerWidthRight = "300px"
              }
          };
      }
}

Add the IThemeHelper theme class(created above) to Services

Somewhere in your program.cs or when setting up DI, call the Extension Method. Info: It's added as a singleton service.

//Add Theme Helper
services.AddMudBlazorThemeHelper<ThemeHelperExample>();

And in your Razor Layouts:

@using Community.Mudblazor.ThemeHelper
...
<MudThemeProvider Theme="@MyCustomTheme" @ref="@_mudThemeProvider" @bind-IsDarkMode="@_isDarkMode" />

```csharp
 @code{
...
    [Inject]
    public IThemeHelper ThemeHelper { get; set; }

    bool _isDarkMode;
    private MudThemeProvider _mudThemeProvider = new MudThemeProvider();

    private MudTheme MyCustomTheme = null;

    protected override async Task OnInitializedAsync()
    {
        MyCustomTheme = ThemeHelper.GetTheme();
    }
...
}


Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 was computed.  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. 
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
1.0.4 179 1/6/2024