MatBlazor components installation

AspNet Core – Server side Blazor framework

Source: https://www.matblazor.com/

If you need open source components for Blazor you definitively need to look at MatBlazor component library.

Installation

  • MatBlazor nuget library
  • EmbeddedBlazorContent nuget library (for server side blazor projects)

Startup.cs

Configure method

// Embedded blazor content get static content from depended DLLs 
app.UseEmbeddedBlazorContent(typeof(MatBlazor.BaseMatComponent).Assembly);

_Imports.razor

Add additional “using” statement for MatBlazor

@using MatBlazor

_Host.cshtml

@addTagHelper *, MatBlazor
@using EmbeddedBlazorContent

<head>
    <!-- static resources from dependent blazor libraries -->
    @Html.EmbeddedBlazorContent()
</head>

Application bar sample

In the NavMenu.razor file add:

<MatAppBarContainer>
    <MatAppBar Fixed="true">
        <MatAppBarRow>
            <MatAppBarSection>
                <MatIconButton Icon="menu"></MatIconButton>
                <MatAppBarTitle>Trade scanner</MatAppBarTitle>
            </MatAppBarSection>
            <MatAppBarSection Align="@MatAppBarSectionAlign.End">
                <MatIconButton Icon="favorite"></MatIconButton>
            </MatAppBarSection>
        </MatAppBarRow>
    </MatAppBar>   
</MatAppBarContainer>

After compile your application should look something like :

Blazor components are encoded without namespaces, it means @addTagHelper and @using statements are in place and working.

2 Replies to “MatBlazor components installation”

  1. Preview 8 with matBlazor 1.6 and embeddedblazorContent 1.4
    I really can’t get it working

    The following line in the configure method : app.UseEmbeddedBlazorContent(typeof(MatBlazor.BaseMatComponent).Assembly);

    PS C:\Users\X\Blazor Projects\WebApplication2> dotnet run
    Startup.cs(37,17): error CS1061: ‘IApplicationBuilder’ does not contain a definition for ‘UseEmbeddedBlazorContent’ and no accessible extension method ‘UseEmbeddedBlazorContent’ accepting a first argument of type ‘IApplicationBuilder’ could be found (are you missing a using directive or an assembly reference?) [C:\Users\X\Blazor Projects\WebApplication2\WebApplication2.csproj]

  2. With Preview 7 and MatBlazor 1.3.0

    Shared\NavMenu.razor(35,39,35,60): error CS0103: The name ‘MatAppBarSectionAlign’ does not exist in the current context

Leave a Reply

Your email address will not be published.