Interactive Hex Color Picker
Color pickers are fundamental UI components in many applications, from design tools to user profile customization. They allow users to select and apply colors to various elements. This problem challenges you to build a simplified interactive color picker component that allows users to select colors from a predefined palette or by entering a hexadecimal code.
Your goal is to implement a ColorPicker React component with the following functionalities:
#RRGGBB). Entering a valid hex code should update the selected color.initialColor prop to set its initial state and an onChange callback prop to communicate color changes to its parent.#) into the input field should update the displayed color and, if the color exists in the palette, highlight the corresponding swatch.aria-label attributes for interactive elements.ColorPicker component accepts initialColor: string and onChange: (color: string) => void props.initialColor on mount.onChange callback with the new hex value.FFFFFF, #123456) into the input field updates the displayed color, highlights the matching palette swatch (if any), and triggers the onChange callback.ABC, GHIJKL) into the input field does not update the selected color; the input should visually indicate an invalid state or revert to the last valid hex value on blur.Constraints
ColorPicker.tinycolor2, color). Basic string parsing for hex codes is expected.#RRGGBB). Support for 3-digit hex codes (e.g., #RGB) is out of scope.onChange.ColorPicker component is structured, its state managed, and props utilized.Loading editor...