Example of Inline Mode in ASP.NET MVC ColorPicker Control
This sample demonstrates the inline (flat) mode ColorPicker with different modes and predefined styles.
Inline Palette
Inline Picker
@Html.UiColorPicker("inline-color-palette", new UiColorPickerOptions { Mode = UiColorPickerMode.Palette, ModeSwitcher = false, Inline = true, ShowButtons = false, OnChange = "onChange" })
@Html.UiColorPicker("inline-color-picker", new UiColorPickerOptions { ModeSwitcher = false, Inline = true, ShowButtons = false, OnChange = "onChange" })
<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="inline-control">
<div id="preview" class="color-preview"></div>
<div id="inline-content" class="color-row">
<div>
<h4>Inline Palette</h4>
@Html.UiColorPicker("inline-color-palette", new UiColorPickerOptions { Mode = UiColorPickerMode.Palette, ModeSwitcher = false, Inline = true, ShowButtons = false, OnChange = "onChange" })
</div>
<div>
<h4>Inline Picker</h4>
@Html.UiColorPicker("inline-color-picker", new UiColorPickerOptions { ModeSwitcher = false, Inline = true, ShowButtons = false, OnChange = "onChange" })
</div>
</div>
</div>
</div>
<script>
// Syncfusion: the preview takes the colour picked in either inline picker
function onChange(args) { document.getElementById('preview').style.backgroundColor = args.value; }
</script>
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/Inline.cshtml; it draws what ViewData holds.
public ActionResult Inline()
{
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,
- Color picker/palette is rendered inline by using the inline
inlineproperty set to true. - Using the
modeproperty, you can specify the mode (Picker/ Palette) of the ColorPicker. - Using the
showButtonsproperty, you can enable or disable the control (apply/cancel) buttons.