Forms

Tailwind CSS Color Picker

Tailwind CSS Color Picker is a modern color selection component built on top of the Pickr library that offers versatile support for various color formats (HEX, RGB, HSL, CMYK), swatches, themes, and customization options, providing responsive and user-friendly color selection solutions for your web projects.

Default Color Picker

To add a basic color picker with default styling, use the data-kt-color-picker attribute on a container element. The color picker will be initialized automatically when the page loads.

Input Mode

To attach a color picker to an input field, use the data-kt-color-picker-input-mode="true" attribute. The color picker will appear when the input is focused and automatically update the input value when a color is selected.

Themes

Pickr supports three different themes: classic (default), monolith , and nano . Use the data-kt-color-picker-theme attribute to change the theme.

Color Swatches

Add predefined color swatches to the color picker for quick selection. Swatches are defined as a comma-separated list of HEX colors using the data-kt-color-picker-swatches attribute.

Color Formats

The color picker supports multiple color formats including HEX, RGB, RGBA, HSL, HSLA, HSVA, and CMYK. The format can be controlled through Pickr's component configuration. By default, HEX, RGBA, and HSLA formats are enabled.

API Interaction

Use the KTColorPicker component's API methods to programmatically control the color picker. You can access methods like show() , hide() , getColor() , reset() , and getPickr() to access the underlying Pickr instance.