New to Telerik UI for ASP.NET Core? 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).
  • None—unset.

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" })
        )
@{
    string[] formats = new string[] { "rgb", "hex" };
}

        <kendo-colorpicker name="picker" value="#ff0000" size="ComponentSize.Medium"
         format="ColorPickerFormat.Rgb"         formats="formats">
        </kendo-colorpicker>

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).
  • None—unset.

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" })
        )
@{
    string[] formats = new string[] { "rgb", "hex" };
}

        <kendo-colorpicker name="picker" value="#ff0000" rounded="Rounded.Medium"
         format="ColorPickerFormat.Rgb"         formats="formats">
        </kendo-colorpicker>

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.
  • None—unset.

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" })
        )
@{
    string[] formats = new string[] { "rgb", "hex" };
}

        <kendo-colorpicker name="picker" value="#ff0000" fillmode="FillMode.Solid"
         format="ColorPickerFormat.Rgb"         formats="formats">
        </kendo-colorpicker>

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 support only the default options when you use a LESS theme.

If you use custom CSS, to override default ColorPicker styles, you will need to update the classes used in the selectors of your custom CSS rules. The following example shows how to achieve the same customization in the ColorPicker, depending on whether you are using an old product version or a new one.

The first set of CSS rules relies on the classes available in the old rendering.

<style>
/*  Old rendering (versions prior to R1 2022)*/      

/* Apply lightblue background color to the ColorPicker's dropdown button */
.k-colorpicker .k-select{ 
  background-color: lightblue;
}

/* Apply green background color to the ColorPicker's Apply button */
.k-flatcolorpicker .apply {
  background-color: green;
  border-color: green;
}

/* Apply red background color and border to the ColorPicker's Cancel button */
.k-flatcolorpicker .cancel {
  background-color: red;
  border-color: red;
}
</style>

The second set of CSS rules relies on the classes available in the new rendering.

<style>
/*  New Rendering (versions after R1 2022) */

/* Apply lightblue background color to the ColorPicker's dropdown button */
.k-colorpicker .k-input-button { 
  background-color: lightblue;
}

/* Apply green background color to the ColorPicker's Apply button */
.k-flatcolorpicker .k-coloreditor-apply {
  background-color: green;
  border-color: green;
}

/* Apply red background color and border to the ColorPicker's Cancel button */
.k-flatcolorpicker .k-coloreditor-cancel {
  background-color: red;
  border-color: red;
}
</style>

See Also

In this article