
Razor Components are the fundamental building blocks of every Blazor application. Each component combines HTML markup, C# logic, and optional CSS in a single .razor file.
@page "/counter"
<h1>Counter</h1>
<p>Current count: @currentCount</p>
<button @onclick="IncrementCount">Click me</button>
@code {
private int currentCount = 0;
private void IncrementCount() { currentCount++; }
}@variable)Counter.razor<Counter />Components are composable — nest them inside other components freely. Each maintains its own state and lifecycle.
Reference:
TaskLoco™ — The Sticky Note GOAT