Getting Started with the Chip
This tutorial explains how to set up a basic Telerik UI for ASP.NET Core Chip and highlights the major steps in the configuration of the component.
You will initialize a Chip control, configure its icons, and handle its events.
Finally, you can run the sample code in Telerik REPL and continue exploring the components.
Prerequisites
To successfully complete the tutorial, you need a project that is already configured to use the Telerik UI for ASP.NET Core components:
You can use the Telerik REPL playground and skip installing the components on your system and configuring a project.
-
You can prepare a Visual Studio project by following either of these guides:
Creating a new pre-configured project for the Telerik UI for ASP.NET Core components from a project template.
Manually configuring an existing project as described in the First Steps on Windows or First Steps on Mac articles.
1. Prepare the CSHTML File
The first step is to add the required directives at the top of the .cshtml
document:
-
To use the Telerik UI for ASP.NET Core HtmlHelpers:
@using Kendo.Mvc.UI
-
To use the Telerik UI for ASP.NET Core TagHelpers:
@addTagHelper *, Kendo.Mvc
2. Initialize the Chip
Use the Chip HtmlHelper or TagHelper to add the component to a page. The Name()
configuration method is mandatory as its value is used for the id
and the name
attributes of the Chip's Html element.
@using Kendo.Mvc.UI
@(Html.Kendo().Chip()
.Name("chip")
)
@addTagHelper *, Kendo.Mvc
<kendo-chip name="chip">
</kendo-chip>
3. Add an Icon
You can display an icon in the Chip by configuring the Icon
option. for more information about the variety of the icons supported by the chip, refer to the article on customizing the chip.
@(Html.Kendo().Chip()
.Name("iconSaveChip")
.Icon("save")
)
@addTagHelper *, Kendo.Mvc
<kendo-chip name="iconSaveChip"
icon="save">
</kendo-chip>
4. Add a Label
To display a label on the Chip, use the Label
option.
@(Html.Kendo().Chip()
.Name("iconSaveChip")
.Icon("save")
.Label("Save")
)
@addTagHelper *, Kendo.Mvc
<kendo-chip name="iconSaveChip"
icon="save"
label="Save">
</kendo-chip>