ColorPicker for standalone color selection and ColorPickerPopover for the inline color picker used in the ThemeCustomizer.
ColorPicker
A full-featured color picker with HSV gradient selector, hue bar, format conversion, and eyedropper support.Props
The current color value as a hex string (e.g.,
"#3b82f6").Callback function called when the color changes. Receives the new hex color string.
The color format to display in the input fields. Options:
ColorFormat.OKLCH- OKLCH color space (lightness, chroma, hue)ColorFormat.HEX- Hexadecimal color codeColorFormat.RGB- RGB values (0-255)ColorFormat.HSL- HSL values (hue 0-360, saturation/lightness 0-100%)
The picker variant to render:
ColorPickerVariant.Free- Shows format selector, allows switching between formatsColorPickerVariant.Predefined- Hides format selector, uses the provided format only
Usage
Features
Interactive Color Selection
The picker provides two interactive controls:- Saturation/Value Square - 2D gradient for selecting color saturation and brightness
- Hue Bar - Linear gradient for selecting color hue (0-360 degrees)
src/components/ColorPicker.tsx:77-127
Format Conversion
Whenvariant is ColorPickerVariant.Free, users can switch between four color formats:
- OKLCH - Perceptually uniform color space with L (0-100%), C (0-0.4), H (0-360°)
- HEX - Standard hexadecimal color code (#RRGGBB)
- RGB - Red, Green, Blue values (0-255 each)
- HSL - Hue (0-360), Saturation (0-100%), Lightness (0-100%)
src/components/ColorPicker.tsx:250-426
Color Name Display
The picker displays a human-readable color name (e.g., “Sky Blue”, “Mystery color”) using thegetColorName utility.
Source: src/components/ColorPicker.tsx:428-430
Copy to Clipboard
Click the copy button to copy the color value in the currently selected format to the clipboard. Shows a check icon for 1.2 seconds after copying. Source:src/components/ColorPicker.tsx:135-153
EyeDropper API
If the browser supports the EyeDropper API, the eyedropper button allows picking colors from anywhere on screen. The button is disabled if the API is not supported. Source:src/components/ColorPicker.tsx:156-173
Types and Enums
src/components/ColorPicker.tsx:15-32
ColorPickerPopover
A popover wrapper aroundColorPicker that displays contrast information and positions itself relative to a color button.
Props
Controls visibility of the popover.
The currently selected color as a hex string, or
null if no color is selected.The theme property name being edited (e.g.,
"primary", "background"), or null.Array of color button configuration objects. Used to find the target contrast ratio for the selected property.
Map of property names to their current contrast ratios.Example:
Horizontal position in pixels for the popover, relative to its container.
Callback function called when the color changes in the picker.
Usage
Features
Contrast Check Panel
The popover displays contrast information at the top:- Current contrast ratio (e.g., “4.5:1”)
- Pass/Fail indicator based on the target ratio
- Target ratio requirement
- Foreground vs Background label (e.g., “primary vs background”)
src/components/ColorPickerPopover.tsx:48-66
Positioning
The popover positions itself above the selected color button using:src/components/ColorPickerPopover.tsx:38-47
Auto-hide
The popover returnsnull when:
isOpenisfalseselectedColorisnullselectedPropertyisnull- No matching button is found in
colorButtons
src/components/ColorPickerPopover.tsx:29-32
Ref Forwarding
The component usesforwardRef to expose its root DOM element, allowing parent components to measure and position it.
Source: src/components/ColorPickerPopover.tsx:16-28
Interface
src/components/ColorPickerPopover.tsx:6-14