Home > Software engineering >  Blazor components (Server-Side). Hide any shared component
Blazor components (Server-Side). Hide any shared component

Time:02-08

Is it possible to display only specific component in Blazor? I dont want to display/show main menu or login button on the top. ONLY content of a particulate component. For example: show only 'Weather forecast' table when user navigates to a specific URL without showing any shared components like MainLayout or NavMenu. enter image description here

CodePudding user response:

Blazor uses a default layout, it is Shared\MainLayout.razor
In there you can see how the menu and top row are setup.

First, define your own minimalist layout:

Shared\ClearLayout.razor

@inherits LayoutComponentBase

<div >
    @Body
</div>

And then add 1 line to the top of FetchData.razor:

@page "/fetchdata"
@layout ClearLayout

<PageTitle>Weather forecast</PageTitle>

...

CodePudding user response:

No offense, but I recommend going through a Blazor course on YouTube, or reading through blazor-university.com as the question you're asking is fairly foundational.

For this question, try:

https://blazor-university.com/layouts/

  •  Tags:  
  • Related