Razor components
Blazor WebAssembly is a component-driven framework. Razor components are the fundamental building blocks of a Blazor WebAssembly application. They are classes that are implemented using a combination of C#, HTML, and Razor syntax. When the web app loads, the classes get downloaded into the browser as normal .NET assemblies (DLLs).
IMPORTANT NOTE
In this book, the terms Razor component and component are used interchangeably.
Using components
HTML element syntax is used to add one component to another component. The markup looks like an HTML tag where the name of the tag is the component type.
The following markup in the Pages/Index.razor
file of the Demo
project, which we will create later in this chapter, will render a SurveyPrompt
instance:
<SurveyPrompt Title="How is Blazor working for you?" />
The preceding SurveyPrompt
element includes an attribute parameter named Title
.
Parameters
Component parameters...