How the useColorPicker hook works
mainThe useColorPicker hook provides complete programmatic control over the picker. It allows you to access the current state (like which gradient point is selected) and manipulate the color values (like changing hue, saturation, or gradient type) without relying on the default UI. This is ideal for building custom UI controls that drive the picker.
import React, { useState } from 'react'
import ColorPicker, { useColorPicker } from 'react-best-gradient-color-picker'
function MyApp() {
const [color, setColor] = useState('linear-gradient(90deg, rgba(96,93,93,1) 0%, rgba(255,255,255,1) 100%)');
const { setSolid, setGradient } = useColorPicker(color, setColor);
return(
<div>
<button onClick={setSolid}>Solid</button>
<button onClick={setGradient}>Gradient</button>
<ColorPicker value={color} onChange={setColor} />
</div>
)
}