Author : MD TAREQ HASSAN | Updated : 2020/08/12

What is RenderFragment?

Basic example

Main.razor

<h1>Title: Main Component</h1>

<h3>Child component is rendered below</h3>

<FooComponent>
	<strong>This text is passsed from Main Component to FooComponent</strong>
</FooComponent>


@code {
    // ... ... ...
}

FooComponent.razor

<h1>Title: Foo Component</h1>

@ChildContent

@code {
    [Parameter]
    public RenderFragment ChildContent { get; set; }
}

The <strong>This text is passsed ...</strong> will be set to FooComponent.ChildContent