Example of Default in ASP.NET MVC Chips Control
This sample demonstrates the default functionalities of Chips with different types and predefined styles. Click and interact with the chip to select single or multiple options from chips collection.
Chips
Apple
Microsoft
Google
Tesla
Intel
Input Chips
Anne
Janet
Laura
MargaretFilter Chips
Extra small
Small
Medium
Large
Extra large
Choice Chips
@Html.UiChipList(new UiChipListOptions
{
Id = "chip-default",
Chips =
{
new UiChip { Text = "Apple", Color = UiButtonColor.Primary },
new UiChip { Text = "Microsoft", Color = UiButtonColor.Info },
new UiChip { Text = "Google", Color = UiButtonColor.Success },
new UiChip { Text = "Tesla", Color = UiButtonColor.Warning },
new UiChip { Text = "Intel", Color = UiButtonColor.Danger }
}
})
@Html.UiChipList(new UiChipListOptions
{
Id = "chip-avatar", EnableDelete = true,
Chips =
{
new UiChip { Text = "Anne", ImageUrl = Url.Content("~/Content/images/chips/anne.png") },
new UiChip { Text = "Janet", ImageUrl = Url.Content("~/Content/images/chips/janet.png") },
new UiChip { Text = "Laura", ImageUrl = Url.Content("~/Content/images/chips/laura.png") },
new UiChip { Text = "Margaret", ImageUrl = Url.Content("~/Content/images/chips/margaret.png") }
}
})
@Html.UiChipList(new UiChipListOptions
{
Id = "chip-filter", Selection = UiChipSelection.Multiple,
Chips = sizes.Select((s, i) => new UiChip { Text = s, Selected = filterSelected.Contains(i) }).ToList()
})
@Html.UiChipList(new UiChipListOptions
{
Id = "chip-choice", Selection = UiChipSelection.Single,
Chips = tasks.Select((s, i) => new UiChip { Text = s, IconCss = taskIcons[i], Outline = true, Selected = choiceSelected.Contains(i) }).ToList()
})
<style>
#chip-default-wrapper { max-width: 640px; margin: 0 auto; }
.chips-headers { font-size: 16px; font-weight: 600; margin: 20px 0 8px; }
.sample-padding { padding: 4px 0; }
</style>
@{
int[] filterSelected = (int[])ViewData["filterSelected"];
int[] choiceSelected = (int[])ViewData["choiceSelected"];
string[] sizes = { "Extra small", "Small", "Medium", "Large", "Extra large" };
string[] tasks = { "Send a text", "Set a reminder", "Read my emails", "Play a game" };
string[] taskIcons = { "ui-icon-text", "ui-icon-alarm", "ui-icon-mail", "ui-icon-game" };
}
<div class="control-section">
<div id="chip-default-wrapper">
<div class="chips-headers">Chips</div>
<div class="sample-padding">
@Html.UiChipList(new UiChipListOptions
{
Id = "chip-default",
Chips =
{
new UiChip { Text = "Apple", Color = UiButtonColor.Primary },
new UiChip { Text = "Microsoft", Color = UiButtonColor.Info },
new UiChip { Text = "Google", Color = UiButtonColor.Success },
new UiChip { Text = "Tesla", Color = UiButtonColor.Warning },
new UiChip { Text = "Intel", Color = UiButtonColor.Danger }
}
})
</div>
<div class="chips-headers">Input Chips</div>
<div class="sample-padding">
@Html.UiChipList(new UiChipListOptions
{
Id = "chip-avatar", EnableDelete = true,
Chips =
{
new UiChip { Text = "Anne", ImageUrl = Url.Content("~/Content/images/chips/anne.png") },
new UiChip { Text = "Janet", ImageUrl = Url.Content("~/Content/images/chips/janet.png") },
new UiChip { Text = "Laura", ImageUrl = Url.Content("~/Content/images/chips/laura.png") },
new UiChip { Text = "Margaret", ImageUrl = Url.Content("~/Content/images/chips/margaret.png") }
}
})
</div>
<div class="chips-headers">Filter Chips</div>
<div class="sample-padding">
@Html.UiChipList(new UiChipListOptions
{
Id = "chip-filter", Selection = UiChipSelection.Multiple,
Chips = sizes.Select((s, i) => new UiChip { Text = s, Selected = filterSelected.Contains(i) }).ToList()
})
</div>
<div class="chips-headers">Choice Chips</div>
<div class="sample-padding">
@Html.UiChipList(new UiChipListOptions
{
Id = "chip-choice", Selection = UiChipSelection.Single,
Chips = tasks.Select((s, i) => new UiChip { Text = s, IconCss = taskIcons[i], Outline = true, Selected = choiceSelected.Contains(i) }).ToList()
})
</div>
</div>
</div>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class ChipsController : Controller
{
// The page is Views/Chips/Default.cshtml; it draws what ViewData holds.
public ActionResult Default()
{
int[] choiceSelected = { 1 };
int[] filterSelected = { 1, 3 };
ViewData["choiceSelected"] = choiceSelected;
ViewData["filterSelected"] = filterSelected;
return View();
}
}
}
@* Install once: Install-Package Lumen.UI.Mvc (or: dotnet add package Lumen.UI.Mvc) *@
@* Views/Web.config: <add namespace="Lumen.UI.Mvc" /> *@
@* Views/Shared/_Layout.cshtml *@
<head>
@Html.UiStyles()
<link rel="stylesheet" href="~/Content/site.css" />
</head>
<body>
@RenderBody()
@Html.UiScripts()
@RenderSection("scripts", required: false)
</body>
Chip is a small block of essential information that triggers an event on click action. It may contain text, an image, or both. It is mostly used in contacts, mails, or filter tags.
In this sample, default, input, filter, and choice chips are demonstrated with their default functionalities.
- Input chip– Basic chip with delete icon enables to remove chips from the chip list collection.
- Choice chip – Used to choose a choice from available options.
- Filter chip – Used to select multiple choices from available options.