Creating Advanced Blazor Components (Part 2)
Building an Alert Component To gain a clearer insight into using render fragments, we’ll create an alert component. The components provided by default utilize Bootstrap, so we will adopt that approach for our component as well. Bootstrap offers numerous components that can be easily adapted for Blazor. In large projects with multiple developers, creating components helps ensure that the entire team maintains a consistent coding style. Let's build a simple alert component, based on Bootstrap: Create a folder by right-clicking on MyBlogServerSide project | Add | New folder and name the folder Components . Create a new Razor file by right-clicking on Components | Add | Razor component and name the component Alert.razor . Replace the content with the Alert.razor file. Add a code section with a RenderFragment property called ChildContent and replace the alert text with the new property. In the code section, add enum containing the different styles available. Add a parameter/pro...