Getting Started with Blazor Block Editor in Blazor Web App
5 Jan 202612 minutes to read
The Blazor Block Editor is a modular, block-based content editor component that enables rich, structured content creation. It provides an intuitive interface for building documents, articles, and collaborative content using customizable blocks such as headings, paragraphs, lists, and more.
This section explains how to integrate the Blazor Block Editor component into a Blazor Web App using Visual Studio, Visual Studio Code, and the .NET CLI.
Prerequisites
Create a new Blazor Web App in Visual Studio
Create a Blazor Web App using Visual Studio 2022 via the Microsoft Templates or the Syncfusion® Blazor Extension. For detailed instructions, refer to the Blazor Web App Getting Started documentation.
Configure the appropriate Interactive render mode and Interactivity location while creating a Blazor Web App. Choose Auto or WebAssembly for interactive components with client-side capabilities, or Server for server-side rendering.

Install Syncfusion® Blazor BlockEditor and Themes NuGet packages in the App
To add the Blazor Block Editor component to the application, open the NuGet package manager in Visual Studio (Tools → NuGet Package Manager → Manage NuGet Packages for Solution), then search and install Syncfusion.Blazor.BlockEditor and Syncfusion.Blazor.Themes.
If using the WebAssembly or Auto render modes in the Blazor Web App, install Syncfusion® Blazor component NuGet packages in the client project.
Alternatively, run the following commands in the Package Manager Console to achieve the same.
Install-Package Syncfusion.Blazor.BlockEditor -Version 32.1.19
Install-Package Syncfusion.Blazor.Themes -Version 32.1.19NOTE
Syncfusion® Blazor components are available in nuget.org. Refer to the NuGet packages topic for the available NuGet packages list with component details.
Prerequisites
Create a new Blazor Web App in Visual Studio Code
Create a Blazor Web App using Visual Studio Code via the Microsoft Templates or the Syncfusion® Blazor Extension. For detailed instructions, refer to the Blazor Web App Getting Started documentation.
Configure the appropriate interactive render mode and interactivity location when setting up a Blazor Web App. For detailed information, refer to the interactive render mode documentation.
For example, to create a Blazor Web App with the Auto interactive render mode, use the following commands:
dotnet new blazor -o BlazorWebApp -int Auto
cd BlazorWebApp
cd BlazorWebApp.ClientInstall Syncfusion® Blazor BlockEditor and Themes NuGet packages in the App
If using the WebAssembly or Auto render modes in a Blazor Web App, install Syncfusion® Blazor component NuGet packages in the client project.
- Press Ctrl+` to open the integrated terminal in Visual Studio Code.
- Ensure the terminal is opened at the project directory containing the .csproj file.
- Run the following commands to install
Syncfusion.Blazor.BlockEditorand Syncfusion.Blazor.Themes NuGet packages and ensure all dependencies are installed.
dotnet add package Syncfusion.Blazor.BlockEditor -v 32.1.19
dotnet add package Syncfusion.Blazor.Themes -v 32.1.19
dotnet restoreNOTE
Syncfusion® Blazor components are available on nuget.org. Refer to the NuGet packages topic for the available NuGet packages list with component details.
Prerequisites
- .NET 8.0 SDK or later
Verify the installed .NET SDK version by executing the following command in a command prompt (Windows) or terminal (macOS/Linux):
dotnet --versionCreate a Blazor Web App using .NET CLI
Run the following command to create a new Blazor Web App in a command prompt (Windows) or terminal (macOS/Linux). For detailed instructions, refer to the Blazor Web App Getting Started documentation.
Configure the appropriate interactive render mode and interactivity location when setting up a Blazor Web App. For detailed information, refer to the interactive render mode documentation.
For example, to create a Blazor Web App with the Auto interactive render mode, use the following commands:
dotnet new blazor -o BlazorWebApp -int Auto
cd BlazorWebApp
cd BlazorWebApp.ClientThis command creates a new Blazor Web App and places it in a new directory called BlazorWebApp inside the current location. See the Create a Blazor App and dotnet new CLI command topics for more details.
Install Syncfusion® Blazor BlockEditor and Themes NuGet packages in the App
To add the Blazor Block Editor component to the application, use the following commands in a command prompt (Windows) or terminal (macOS/Linux) to install the Syncfusion.Blazor.BlockEditor and Syncfusion.Blazor.Themes NuGet packages. See Install and manage packages using the dotnet CLI for more details.
If using the WebAssembly or Auto render modes in the Blazor Web App, install Syncfusion® Blazor component NuGet packages in the client project.
dotnet add package Syncfusion.Blazor.BlockEditor --version 32.1.19
dotnet add package Syncfusion.Blazor.Themes --version 32.1.19
dotnet restoreNOTE
Syncfusion® Blazor components are available in nuget.org. Refer to the NuGet packages topic for the available NuGet package list with component details.
Add Import Namespaces
Open the ~/_Imports.razor file in the client project and import the Syncfusion.Blazor and Syncfusion.Blazor.BlockEditor namespaces.
@using Syncfusion.Blazor
@using Syncfusion.Blazor.BlockEditorRegister Syncfusion® Blazor Service
Register the Syncfusion® Blazor Service in the ~/Program.cs file of the Blazor Web App.
If the Interactive Render Mode is set to WebAssembly or Auto, register the Syncfusion® Blazor service in the ~/Program.cs files of both the main server project and the associated .Client project.
...
...
using Syncfusion.Blazor;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents()
.AddInteractiveWebAssemblyComponents();
builder.Services.AddSyncfusionBlazor();
var app = builder.Build();
.......
using Syncfusion.Blazor;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.Services.AddSyncfusionBlazor();
await builder.Build().RunAsync();Add stylesheet and script resources
The theme stylesheet and script can be accessed from NuGet through Static Web Assets. Include the stylesheet reference in the <head> section and the script reference at the end of the <body> in the ~/Components/App.razor file as shown below:
<head>
....
<link href="_content/Syncfusion.Blazor.Themes/bootstrap5.css" rel="stylesheet" />
</head>
....
<body>
....
<script src="_content/Syncfusion.Blazor.Core/scripts/syncfusion-blazor.min.js" type="text/javascript"></script>
</body>NOTE
Check out the Blazor Themes topic to discover various methods (Static Web Assets, CDN, and CRG) for referencing themes in your Blazor application. Also, check out the Adding Script Reference topic to learn different approaches for adding script references in your Blazor application.
Add Syncfusion® Blazor Block Editor component
Add the Syncfusion® Blazor Block Editor component to a Razor page located in the Components/Pages folder (e.g., Components/Pages/Home.razor) in the Server project or the Pages folder in the Client project. If an interactivity location is set to Per page/component in the web app, define a render mode at the top of the component, as follows:
| Interactivity location | RenderMode | Code |
|---|---|---|
| Per page/component | Auto | @rendermode InteractiveAuto |
| WebAssembly | @rendermode InteractiveWebAssembly | |
| Server | @rendermode InteractiveServer |
NOTE
If an Interactivity Location is set to
Globaland the Render Mode is set toAutoorWebAssembly, the render mode is configured in theApp.razorfile by default.
@* Define desired render mode here *@
@rendermode InteractiveAuto<SfBlockEditor></SfBlockEditor>- Press Ctrl+F5 (Windows) or ⌘+F5 (macOS) to launch the application. This renders the Syncfusion® Blazor Block Editor component in the default web browser.
Configure blocks
The Block Editor uses a block-based content structure where each block represents a specific content type (heading, paragraph, list, etc.). The Blocks property manages and configures these blocks, allowing full control over the content structure and presentation.
<SfBlockEditor @bind-Blocks="blockDataOverview">
</SfBlockEditor>
@code {
private List<BlockModel> blockDataOverview = new EditorBlockData().GetBlockDataOverview();
public class EditorBlockData
{
public List<BlockModel> GetBlockDataOverview()
{
List<BlockModel> blockDataOverview = new List<BlockModel>
{
new BlockModel
{
BlockType = BlockType.Heading,
Properties = new HeadingBlockSettings{ Level=2 },
Content =
{
new ContentModel
{
ContentType = ContentType.Text,
Content = "Getting Started with Block Editor"
}
}
},
new BlockModel
{
BlockType = BlockType.Paragraph,
Content =
{
new ContentModel { ContentType = ContentType.Text, Content = "Welcome to" },
new ContentModel { ContentType = ContentType.Text, Content = " Block Editor", Properties = new TextContentSettings { Styles = new StyleModel { Bold = true } } },
new ContentModel { ContentType = ContentType.Text, Content = " - your flexible, modular workspace for creating rich, structured content. Whether you're drafting documents, brainstorming ideas, or collaborating with your team, Block Editor makes it simple and intuitive." }
}
},
new BlockModel { BlockType = BlockType.Paragraph, Content = new List<ContentModel>() }
};
return blockDataOverview;
}
}
}
NOTE