Introduction
In this article, we will learn how we implement multiple render fragments in Blazor. A piece of the UI to be rendered is represented by a render fragment in Blazor, a single RenderFragment is used to specify the location of a component's children. Moreover, providing multiple RenderFragments is also possible with Blazor in your component, you added several RenderFragment attributes. The [Parameter] attributes must be used. The Blazor framework is aware enough to understand the proper definition of a RenderFragment and can assist you if there are any compilation or usage difficulties with the Component.
Step 1
create a new project in visual studio and select Blazor WebAssembly App. Create two razor components first one is ParentComponent and the second one is ChildComponent.Now we have to define a page directive to give the path.
@page "/ParentComponent"
<h3>Parent Child relation</h3>
@code {
}
we will add one new nav link in Navmenu.razor.
<div class="nav-item px-3">
<NavLink class="nav-link" href="ParentComponent">
<span class="oi oi-people" aria-hidden="true"></span> parent-child
</NavLink>
</div>
Output

Step 2
In ChildComponent we will create one string property name as Title with [parameter]. Then create a div and pass the property as @Title
<div>
<div class="alert alert-info">@Title</div>
</div>
@code {
[Parameter]
public string Title{ get; set; }
}
In Parent.razor page we have to pass ChildComponent
<ProjectWeb_Server.Pages.component.NewFolder.ChildComponent Title="HEY !! From Parent Component"></ProjectWeb_Server.Pages.component.NewFolder.ChildComponent>
add this in _imports.razor to reduce component name
@using ProjectWeb_Server.Pages.component.NewFolder
In Parent.razor
<ChildComponent Title="HEY !! From Parent Component"></ChildComponent>
Output




Join the conversation! Your thoughts help the community grow.