Blazor University Learn the .NET SPA framework from Microsoft
Ctrl X

I am available for contract work, contact me via Linked-in or Email.

Creating a Blazor layout

Any content you intend to act as a layout template for pages must descend from the LayoutComponentBase class. To indicate where you want the content of your page to appear you simply output the contents of the Body property.

@inherits LayoutComponentBase

<div class="main">
    <h1>This is the header</h1>

  <div class="content">

    This is the footer

Note that this is not the entire HTML page. Blazor layouts work only within the part of the HTML that Blazor is defined within the wwwroot\index.html page, in a default Blazor application this is everything within the <app> element. It isn't currently possible to alter attributes of HTML elements outside of this scope except by use of JavaScript Interop.