Example of Default Functionalities in ASP.NET MVC ColorPicker Control
This sample demonstrates the default functionalities of the color picker/palette with default colors and predefined styles.
Choose a color
@Html.UiColorPicker("color-picker", new UiColorPickerOptions())
<style>
#default-control, #inline-control, #custom-control, #colorpicker-control { text-align: center; padding: 20px 0; }
#default-control h4, #colorpicker-control h4, #inline-control h4 { margin: 0 0 12px; font-size: 14px; font-weight: 600; }
.color-preview { width: 120px; height: 80px; margin: 0 auto 16px; border: 1px solid var(--ui-border); border-radius: 8px; background: #008000; }
.color-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 28px; }
.property-section .property-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; }
.property-section .prop-input { width: 110px; padding: 4px 6px; border: 1px solid var(--ui-input-border); border-radius: var(--ui-radius); background: var(--ui-surface); color: var(--ui-text); font: inherit; }
</style>
<div class="control-section">
<div id="default-control">
<h4>Choose a color</h4>
@Html.UiColorPicker("color-picker", new UiColorPickerOptions())
</div>
</div>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class ColorPickerController : Controller
{
// The page is Views/ColorPicker/DefaultFunctionalities.cshtml; it draws what ViewData holds.
public ActionResult DefaultFunctionalities()
{
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>
The ColorPicker component is a user interface to select and adjust color values. This supports various color specifications like RGB (Red Green Blue), HSV (Hue Saturation Value), and Hex codes.
In this sample, the ColorPicker popup contains picker area, slider to adjust hue and opacity value, input textarea, and control buttons.
- Drag the handle in the picker area to select your favorite color.
- You can manually set the color by typing the color values in the input text boxes.
- By clicking the format switching icon at the right side of the input text area, switch between palette and picker mode.
- By clicking the mode switching icon at the left bottom of the popup, switch between palette and picker mode.
- Using the
valueproperty, set the color value to picker and palette initially.