New to Telerik UI for ASP.NET MVC? Download free 30-day trial

ColorPicker Appearance

As of the R1 2022 release, the ColorPicker component uses a new rendering. To learn more about the reasons for this decision, see the Components Appearance article.

For a live example of the ColorPicker styling options, visit the ColorPicker Appearance Demo.

Options

The ColorPicker supports the following styling options:

  • Size—configures the overall size of the component.
  • Rounded—configures the border radius of the component.
  • FillMode—configures how the color is applied to the component.

Size

The Size option controls the size of the ColorPicker. The k-input-{size} class, which is applied to the wrapping span element of the ColorPicker, reflects the value of the Size option.

The following values are available for the Size option:

  • Small—small size (applies the k-input-sm class to the wrapping span element).
  • Medium—medium size (applies the k-input-md class to the wrapping span element).
  • Large—large size (applies the k-input-lg class to the wrapping span element).

The following example demonstrates how to set Size in the declaration of the ColorPicker:

    @(Html.Kendo().ColorPicker()
        .Name("picker")
        .Size(ComponentSize.Medium)
        .Value("#ff0000")
        .Format(ColorPickerFormat.Rgb)
        .Formats(new string[] { "rgb", "hex" })
    )

The default Size value is Medium and it is applied to the wrapping span element through the k-input-md class.

<span class="k-colorpicker k-picker k-picker-md">
</span>

Rounded

The Rounded option controls the border radius of the ColorPicker. The class that corresponds to the Rounded option is k-rounded-{rounded}.

The following values are available for the Rounded option:

  • Small—small border radius (applies the k-rounded-sm class to the wrapping span element).
  • Medium—medium border radius (applies the k-rounded-md class to the wrapping span element).
  • Large—large border radius (applies the k-rounded-lg class to the wrapping span element).
  • Full—largest border radius (applies the k-rounded-full class to the wrapping span element).

The following example demonstrates how to set Rounded in the declaration of the ColorPicker:

    @(Html.Kendo().ColorPicker()
        .Name("picker")
        .Rounded(Rounded.Medium)
        .Value("#ff0000")
        .Format(ColorPickerFormat.Rgb)
        .Formats(new string[] { "rgb", "hex" })
    )

The default Rounded value is Medium and it is applied to the wrapping span element through the k-rounded-md class.

<span class="k-colorpicker k-picker k-rounded-md">
</span>

FillMode

The FillMode option controls the way color is applied to the rendered ColorPicker. The k-picker-{fillMode} class, which is applied to the wrapping span element of the ColorPicker, reflects the value of the FillMode option.

The following values are available for the FillMode option:

  • Solid—applies the k-input-solid class to the wrapping span element.
  • Flat—applies the k-input-flat class to the wrapping span element.
  • Outline—applies the k-input-outline class to the wrapping span element.

The following example demonstrates how to set FillMode in the declaration of the ColorPicker:

    @(Html.Kendo().ColorPicker()
        .Name("picker")
        .FillMode(FillMode.Solid)
        .Value("#ff0000")
        .Format(ColorPickerFormat.Rgb)
        .Formats(new string[] { "rgb", "hex" })
    )

The default FillMode value is Solid and it is applied to the wrapping span element through the k-input-solid class.

<span class="k-colorpicker k-input k-input-solid">
</span>

Old vs New Rendering

Below you will find the differences between the old and the new rendering.

Old Rendering:

...
...

New Rendering:

    <!-- no tool icon -->
    <span class="k-value-icon k-color-preview  k-no-color">
        <!-- k-no-color is added when value is null -->
        <span class="k-color-preview-mask" style="background-color: rgb(255, 255, 255);"></span>
    </span>


    <!-- with tool icon -->
     <span class="k-value-icon k-color-preview k-icon-color-preview k-no-color">
         <!-- k-no-color is added when value is null -->
         <span class="k-color-preview-icon k-icon k-i-edit-tools {toolIcon}"></span>
         <span class="k-color-preview-mask" style="background-color: rgb(255, 255, 255);"></span>
     </span>
</span>
<button class="k-select k-input-button k-button k-button-{size} k-rounded-{rounded} k-button-{fillMode} k-button-{fillMode}-base k-icon-button" unselectable="on" aria-label="select" type="button">
    <span class="k-icon k-i-arrow-s k-button-icon"></span>
</button>
<input id="colorpicker" data-role="colorpicker" style="display: none;">

...
...

The following example demonstrates how to configure the appearance of the component through configuration:

    @(Html.Kendo().ColorPicker()
        .Name("picker")
        .Size(ComponentSize.Medium)
        .Rounded(Rounded.Medium)
        .FillMode(FillMode.Solid)
        .Value("#ff0000")
        .Format(ColorPickerFormat.Rgb)
        .Formats(new string[] { "rgb", "hex" })
    )

Visual Backwards Compatibility

In order to achieve the same look and feel as the old rendering, the element references must be updated. Visit the CSS Classes Migration and JQuery Selectors Migration sections of the Styling Overview article for additional information.

The new styling and rendering supports only the default options when you use a LESS theme.

See Also

In this article