How do you dynamically create a component?

Platform: Blazor| Category: Components

The RenderFragment is used to create a component dynamically.

 @page "/"
  
 @CreateDynamicComponent();
 @code {
     RenderFragment CreateDynamicComponent() => builder =>
     {
         builder.OpenComponent(0, typeof(SurveyPrompt));
         builder.AddAttribute(1, "Title", "Some title");
         builder.CloseComponent();
     };
 } 

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.