Randy Marsh
Randy Marsh

Reputation: 97

Blazor components (Server-Side). Hide any shared component

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

Upvotes: 1

Views: 932

Answers (1)

Henk Holterman
Henk Holterman

Reputation: 273179

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 class="page">
    @Body
</div>

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

@page "/fetchdata"
@layout ClearLayout

<PageTitle>Weather forecast</PageTitle>

...

Upvotes: 3

Related Questions