Follow these steps to integrate MudBlazor.Markdown into your project:
1. Add Using Statement
Add the following to your _Imports.razor file:
@using MudBlazor
2. Add MudBlazor Providers
Add these components to App.razor or MainLayout.razor:
<MudThemeProvider />
<MudPopoverProvider />
<MudDialogProvider />
<MudSnackbarProvider />
3. Add Static Assets
In the <head> node of Pages/_Host.cshtml (Server) or wwwroot/index.html (WebAssembly), add these stylesheets:
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet" />
<link href="_content/MudBlazor/MudBlazor.min.css" rel="stylesheet" />
<link href="_content/MudBlazor.Markdown/MudBlazor.Markdown.min.css" rel="stylesheet" />
At the bottom of the <body> node, add these scripts:
<script src="_content/MudBlazor/MudBlazor.min.js"></script>
<script src="_content/MudBlazor.Markdown/MudBlazor.Markdown.min.js"></script>
4. Register Services
Register the required services in your DI container.
Blazor Server (Startup.cs):
public void ConfigureServices(IServiceCollection services)
{
services.AddMudServices();
services.AddMudMarkdownServices();
// Optionally add a custom clipboard service if the default fails
services.AddMudMarkdownClipboardService<MauiClipboardService>();
}
Blazor WebAssembly (Program.cs):
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.Services.AddMudServices();
builder.Services.AddMudMarkdownServices();
// Optionally add a custom clipboard service if the default fails
builder.Services.AddMudMarkdownClipboardService<MauiClipboardService>();