Skip to main content

onChange

Description

Optional. Fires when a new value is selected in the control

Usage

onChange?: (ev: { value: string }) => void;

Parameters

The callback of the event takes an object with the following parameter:

  • value - (required) HEX code of the newly selected color

Example

function App() {
function handleChange({ value }: { value: string }) {
console.log(value);
// HEX code
}

return <ColorSelect onChange={handleChange} />;
}

Details

The handler function receives an object with the HEX code of the newly selected color.

Related article: Catching the change of selected options