Templated components can be implemented using a class called RenderFragment. They are implement same like a parameter property but they capture the content declared inside the component tags.
Below is an example from the default Blazor project. I updated the SurveyPrompt component to take in the question content like this
<div class="alert alert-secondary mt-4" role="alert">
<span class="oi oi-pencil mr-2" aria-hidden="true"></span>
<strong>@Title</strong>
<span class="text-nowrap">
@ChildContent
<a target="_blank" class="font-weight-bold" href="https://go.microsoft.com/fwlink/?linkid=2127996">brief survey</a>
</span>
</div>
@code {
[Parameter]
public string Title { get; set; }
[Parameter]
public RenderFragment ChildContent { get; set; }
}
Here is how i pass the content to the Survey component
<SurveyPrompt Title="How is Blazor working for you?">
<i class="carousel-control-next-icon"></i>Please take our survey below
</SurveyPrompt>
You can also have the RenderFragment typed, read more about it here:
https://learn.microsoft.com/en-us/aspnet/core/blazor/templated-components?view=aspnetcore-3.1