In this example, the Color Picker Control instance is allowed to create its own DOM structure. We begin with a simple style set for the containing element into which that DOM structure will be rendered and we place the containing element on the page:
With a target element in place, we can instantiate Color Picker and provide our desired configuration options. In this example, we are specifying that HSV and hex controls should be displayed and we're specifying custom locations for the color-picker slider thumb and the hue slider thumb. For the purposes of the example, we're also hooking into the Color Picker's
rgbChange event and logging the
newValue to the logger console; you'll see those log messages each time you adjust the color. This example also demonstrates how to use the picker's
get method to tap into the current
hex value via script.
It's advisable to provide all necessary configurations at the instantiation of the Color Picker; it renders immediately and automatically upon creation.