SubComponents
Control
The control subcomponent is required to render the Control
of the ColorPicker component. Because of this, this component extends the native div props. Because of this, you can use all of the native props. This is a required children.
Control API
Notice that there is a difference between using isDisabled
here or in the parent component. It is not recommended to change this props in the Control
subcomponent, because this props can be inherited from the Wrapper
. If you use it in the Control
subcomponent, you will get the state only in the field.
hex
string
❌
rgb
{ r:number, g: number, b: number, a?: number}
❌
hsl
{h: number, s: number, l: number, a?: number}
❌
defaultHex
string
❌
defaultRgb
{ r:number, g: number, b: number, a?: number}
❌
defaultHsl
{h: number, s: number, l: number, a?: number}
❌
defaultColorFormat
'rgb' | 'hsl' | 'hex';
❌
onColorChange
(e: ColorPickerChangeEventProps ) => void;
❌
HelpText
The HelpText subcomponent extends the SDS label component. See for reference: HelpText.
Label
The Label subcomponent extends the SDS label component. See for reference: Label.
Utilities
Interacting with colors can be complicated, more taking in consideration there are a lot of different tools to work with them. By default, the Color Picker component offers developers some utilities that can help them with the color convertions.
colorPickerRgbToString: Transforms the rgb object the Color Picker returns into a string with the correct format.
colorPickerHslToString: Transforms the hsl object the Color Picker returns into a string with the correct format.
colorPickerStringValidator: Validates string colors. It can receive hex, rgb and hsl string values.
colorPickerStringToColor: Transforms string colors into selected color format.
Last updated