This section briefly explains how to include a Chip
in your Blazor Server-Side application. Refer to the Getting Started with Syncfusion Blazor for Server-Side in Visual Studio 2019 page for the introduction and configuring the common specifications.
NuGet Package Manager
.You can add the client-side style resources using NuGet package to the <head>
element of the ~/wwwroot/index.html
page in Blazor WebAssembly app or ~/Pages/_Host.cshtml
page in Blazor Server app.
Note: You can also add the client-side style resources through CDN.
<head>
....
....
<link href="_content/Syncfusion.Blazor/styles/bootstrap4.css" rel="stylesheet" />
</head>
<head>
<link href="https://cdn.syncfusion.com/blazor/18.4.35/styles/bootstrap4.css" rel="stylesheet" />
</head>
Internet Explorer 11
kindly refer the polyfills. Refer the documentation for more information.<head>
<link href="_content/Syncfusion.Blazor/styles/bootstrap4.css" rel="stylesheet" />
<script src="https://github.com/Daddoon/Blazor.Polyfill/releases/download/3.0.1/blazor.polyfill.min.js"></script>
</head>
NuGet Package Manager
.Warning: Syncfusion.Blazor
package should not be installed along with individual NuGet packages. Hence, you have to add the below Syncfusion.Blazor.Themes
static web assets (styles) in the application.
<head>
element of the ~/wwwroot/index.html
page in Blazor WebAssembly app or ~/Pages/_Host.cshtml
page in Blazor Server app. <head>
....
....
<link href="_content/Syncfusion.Blazor.Themes/bootstrap4.css" rel="stylesheet" />
</head>
Warning: If you prefer the above new standard (individual NuGet packages), then skip this section. Using both old and new standards in the same application will throw ambiguous compilation errors.
Open the Startup.cs file and add services required by Syncfusion components using services.AddSyncfusionBlazor()
method. Add this method in the ConfigureServices
function as follows.
using Syncfusion.Blazor;
namespace BlazorApplication
{
public class Startup
{
....
....
public void ConfigureServices(IServiceCollection services)
{
....
....
services.AddSyncfusionBlazor();
}
}
}
Open the Program.cs file and add services required by Syncfusion components using builder.services.AddSyncfusionBlazor()
method. Add this method in the Main
function as follows.
using Syncfusion.Blazor;
namespace BlazorApplication
{
public class Program
{
public static async Task Main(string[] args)
{
....
....
builder.Services.AddSyncfusionBlazor();
}
}
}
Note: To enable custom client side resource loading from CRG or CDN. You need to disable resource loading by AddSyncfusionBlazor(true) and load the scripts to the <head>
element of the ~/wwwroot/index.html page in Blazor WebAssembly app or ~/Pages/_Host.cshtml page in Blazor Server app.
<head>
<script src="https://cdn.syncfusion.com/blazor/18.4.35/syncfusion-blazor.min.js"></script>
</head>
Open ~/_Imports.razor
file and import the Syncfusion.Blazor.Buttons
package.
@using Syncfusion.Blazor
@using Syncfusion.Blazor.Buttons
Now, add the Syncfusion Blazor Chip component in any web page razor
in the Pages
folder. For example, the Chip component is added in the ~/Pages/Index.razor
page.
@using Syncfusion.Blazor.Buttons
<SfChip>
<ChipItems>
<ChipItem Text="Janet Leverling"></ChipItem>
</ChipItems>
</SfChip>
After successful compilation of your application, simply press F5
to run the application.
Output be like the below.
Getting Started with Syncfusion Blazor for Client-Side in .NET Core CLI
Getting Started with Syncfusion Blazor for Client-Side in Visual Studio 2019
Getting Started with Syncfusion Blazor for Server-Side in .NET Core CLI