Add Syncfusion Blazor component in the Blazor application
26 Aug 20212 minutes to read
The Syncfusion Blazor code snippet utility for Visual Studio Code provides snippets for adding a Syncfusion Blazor component with various features in the Razor code editor file of the Blazor Application.
The Syncfusion Blazor code snippet is available from Essential Studio 2021 Volume 1 (
Add a Syncfusion Blazor component
The following steps help to use the Syncfusion Blazor code snippet in the Blazor Application.
Open an existing Blazor Application or create a new Blazor Application in Visual Studio Code.
Open the required razor file.
The Syncfusion Blazor component can be found with the various features by typing the word in the following format.
sf<Syncfusion component name>-<Syncfusion component feature> For Example, sfgrid-grouping
Choose the Syncfusion component and click the Enter or Tab key, the Syncfusion Blazor component will be added in the razor file.
After adding the Syncfusion Blazor component in the razor file, use the tab key to fill the required values to render the component. The comment section can be found in the code snippet to find the values that needs to be filled.
Also, the Syncfusion help link can be found at the top of the added snippet to know more about the added Syncfusion Blazor component feature.
Configure Blazor application with Syncfusion
The Syncfusion Blazor snippet only adds the code in the razor file. The Blazor application needs to be configured with Syncfusion by adding the required Syncfusion Blazor NuGet, namespace, themes, and register the Syncfusion Blazor Service. Refer to the following steps to configure:
Open the Blazor project file and add the required Syncfusion Blazor individual NuGet package(s) for the Syncfusion Blazor components as a package reference manually. Refer to this section to know the benefits of the individual NuGet packages. This NuGet package will be automatically restored when building the application.
Starting with Volume 4, 2020 (v184.108.40.206) release, Syncfusion provides individual NuGet packages for the Syncfusion Blazor components. This new standard is highly recommended for the Blazor production applications.
Open the ~/_Imports.razor file and add the required Syncfusion Blazor namespace entries to render the Syncfusion components in the application.
Add the Syncfusion Blazor theme in the
<head>element of the ~/Pages/_Host.html page for server application and ~/wwwroot/index.html page for a client application.
Open the ~/Startup.cs file for server application and the ~/Program.cs file for client application then register the Syncfusion Blazor Service.
If the trial setup or NuGet packages are installed from the nuget.org, the Syncfusion license key has to be registered to the project since Syncfusion introduced the licensing system from 2018 Volume 2 (v220.127.116.11) Essential Studio release. Navigate to the help topic to generate and register the Syncfusion license key to the project. Refer to this blog post for understanding the licensing changes introduced in Essential Studio.