Color Picker
Alias: Umbraco.ColorPicker
Returns: String (Hexadecimal)
Returns: Umbraco.Cms.Core.PropertyEditors.ValueConverters.ColorPickerValueConverter.PickedColor (When using labels)
The Color picker allows you to set some predetermined colors that the editor can choose between.
It's possible to add a label to use with the color.

Color Picker Data Type Definition

Color Picker Content
@{
var hexColor = Model.Color;
// Define the label if you've included it
String colorLabel = Model.Color.Label;
if (hexColor != null)
{
<div style="background-color: #@hexColor">@colorLabel</div>
}
}
@using Umbraco.Cms.Core.PropertyEditors.ValueConverters
@{
var hexColor = Model.Value("Color");
// Define the label if you've included it
var colorLabel = Model.Value<ColorPickerValueConverter.PickedColor>("Color").Label;
if (hexColor != null)
{
<div style="background-color: #@hexColor">@colorLabel</div>
}
}
See the example below to see how a value can be added or changed programmatically. To update a value of a property editor you need the Content Service.
@inject IContentService Services;
@using Umbraco.Cms.Core.Services;
@{
// Get access to ContentService
var contentService = Services;
// Create a variable for the GUID of the page you want to update
var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef");